What is a JSON Merge Tool?
A JSON merge tool combines two or more JSON documents into a single JSON document according to defined merge rules. You give it each object separately, and it gives you back one object where every key from every input is present, resolved using consistent rules rather than by hand.
The rules are what make a merge trustworthy. Later documents take priority when the same key appears twice, nested objects are merged recursively so adding settings.db.port does not wipe out settings.db.host, and arrays are replaced instead of being quietly concatenated. You can read the same rules in the Keys taken from a later JSON list underneath every result, so the precedence is always visible and never a surprise.
That combination makes it the tool for development work rather than a toy: layering a configuration file over a set of defaults, folding two API responses into one payload, assembling a large test fixture from small readable pieces, or producing a single clean JSON document to pass to a converter or a script.
Everything runs locally in your browser. Nothing is uploaded, so a customer record, an internal API response or a config file with secrets in it never leaves your machine.
How to merge JSON
Merging JSON takes five steps: provide the documents, add any extra ones you need, merge them, check which keys came from a later document, then copy the result.
- Paste your first JSON object into JSON 1 and the second into JSON 2. Load example fills several inputs for you if you just want to watch the merge happen.
- Click + Add JSON for each extra document. JSON 3, JSON 4 and beyond appear immediately, each with its own editor, and JSON 3 onwards can be removed again with its Remove button.
- Click Merge JSON. Every input that contains JSON is parsed and merged from top to bottom into one document.
- Read the merged result. Keys that took their value from a later JSON are listed underneath, so you can confirm which document won.
- Copy the merged JSON with the Copy button and paste it wherever you need it. Ctrl+Enter merges without leaving the keyboard.
Nothing is uploaded and no account is needed. The merge runs in your browser, so the same steps work for a four-line snippet and for a large API response copied straight out of your browser's network tab.
JSON merge example
These two objects share one key. Merging them adds city, and age is taken from JSON 2 because the later document wins the conflict.
The result is a single valid JSON document, not a string, not a description of the objects - the actual merged JSON, indented and ready to copy.
{
"name": "John",
"age": 30
}{
"city": "Lahore",
"age": 31
}{
"name": "John",
"age": 31,
"city": "Lahore"
}How JSON merging works
Every merge follows the same seven rules, whether you merge two documents or ten. They are listed below exactly as the tool applies them, including the two cases that are easy to get wrong: arrays and type changes.
The rules matter because a merge is destructive in a quiet way if you guess them. Replace the array and a skills list does not silently grow a duplicate entry; keep the nested branch and settings.db.host survives when you only meant to change the port. Where a later document really did override an earlier key, the result lists the path, the value it replaced and the JSON number that supplied the new one.
| Merge rule | What the tool does |
|---|---|
| Later documents win | Inputs merge from top to bottom. When the same key appears in more than one document, the value from the later document is used. |
| Nested objects merge recursively | Two objects under the same key are merged key by key to any depth, so a new nested value is added rather than replacing the whole branch. |
| Arrays are replaced | An array is never treated as an object and is never concatenated with another array. The later array replaces the earlier one. |
| Type conflicts use the later value | Object to primitive, primitive to object, object to array, array to object, number to string, boolean to number and null to a value all resolve to the later value, without any coercion. |
| Equal values are not conflicts | A key whose value is identical in both documents is merged silently, so the override list only shows genuine changes. |
| Invalid JSON is rejected | If any input does not parse, the merge is not run. The failing input is named with the line and column of the syntax error, your text is left untouched, and no partial result is produced. |
| Empty inputs are skipped | An input with no text contributes nothing and is counted separately, so an unused added input never discards the documents around it. |
Merging nested objects, arrays and types
This second example shows the recursive and replacement rules together. JSON 2 adds user.city, so the user object keeps name and age rather than being overwritten, and skills is replaced outright because it is an array.
The same rule covers a type change: a key that holds an object in one document and a string, number or array in another takes the later value, exactly as if the two values had the same type.
{
"user": {
"name": "John",
"age": 25
},
"skills": ["JavaScript", "Python"]
}{
"user": {
"city": "Lahore"
},
"skills": ["React"]
}{
"user": {
"name": "John",
"age": 25,
"city": "Lahore"
},
"skills": [
"React"
]
}Why merge JSON objects?
Merging is what you reach for when the data you need is spread across more than one document and you want it as one. Keeping the sources separate is usually the right design - separate files are easier to review, easier to reuse and easier to maintain - and merging is simply the step that turns them back into the single document your code or API expects.
It is also the quickest way to see what an override actually changes. Instead of rebuilding the expected object by hand to check a config edit, you merge base plus override and inspect the result.
Layering configuration
Keep a base config and an environment override as separate documents, then merge them into the effective configuration your app actually runs.
Combining API responses
Combine a paginated response with the next page, or fold enrichment data from another endpoint into the same payload.
Applying defaults
Merge user-provided settings over a defaults object so only the keys they actually set are changed.
Assembling test fixtures
Build a large expected payload from small readable fragments instead of hand-maintaining one enormous JSON file.
Preparing structured data
Produce one clean JSON document to feed a converter, an API request body, a script or a data pipeline.
Reviewing a change
Merge two variants of a payload and then compare the result against a known-good fixture with the JSON Diff tool.
When to merge and when to compare
Merging and diffing answer different questions, and picking the wrong one costs time. A merge asks: what does this look like once everything is combined? A diff asks: what changed between these two documents?
So if you are building a single payload from several sources, merge. If you are checking whether a deploy changed an API response, whether a config edit did what you expected, or whether a fixture still matches, diff the two documents instead - that is exactly what the JSON Diff tool is for.
Related JSON tools
Merging is one step in a JSON workflow. These are the other Calzyra tools you are most likely to reach for next.
- Need to compare two documents instead of combining them?JSON Diff Tool
- Need to tidy the merged result before you save it?JSON Formatter
- Need the merged JSON stripped of whitespace?JSON Minifier – Minify JSON Online
- Need to confirm the merged result is valid JSON?JSON Validator – Validate JSON Online
- Need to explore the merged structure as collapsible nodes?JSON Tree Viewer
- Need a flat key-value view of the same nesting?JSON Flattener
- Need YAML output instead?JSON to YAML Converter
- Need an XML document instead?JSON to XML Converter
- Need the merged data as rows and columns?JSON to CSV Converter
Frequently Asked Questions
What is a JSON Merge Tool?
A JSON Merge Tool combines two or more JSON documents into a single JSON object using defined merge rules. You paste each document into its own input, press Merge JSON, and get one valid JSON document back. This tool merges objects key by key, gives the later document priority when the same key appears twice, merges nested objects recursively and replaces arrays instead of joining them. It is the tool you want when you need one combined JSON result rather than a comparison of two documents.
How do I merge two JSON objects?
Paste the first object into JSON 1 and the second into JSON 2, then press Merge JSON. The result appears under Merged JSON, formatted with two-space indentation and ready to copy. Merging also runs on Ctrl+Enter, and a loaded example fills both inputs for you if you want to see the behaviour before entering your own data.
Can I merge more than two JSON files?
Yes. The tool starts with JSON 1 and JSON 2, and the + Add JSON button appends JSON 3, then JSON 4, and so on, up to twelve documents in a single merge. Each input keeps its own text, so you can add documents one at a time, merge what you have, then add another without retyping anything.
Which JSON value wins when the same key exists in multiple inputs?
The later document wins. Inputs are merged from top to bottom, so JSON 2 overrides JSON 1, JSON 3 overrides both, and the last document that contains a key supplies its value. After a merge you can expand the list of overridden keys to see exactly which JSON supplied each value and what it replaced.
Does JSON Merge support nested objects?
Yes, and nested objects are merged recursively rather than replaced. If JSON 1 holds user.name and JSON 2 holds user.city, the result keeps both inside the same user object. That continues to any depth, so a deep override such as settings.features.beta only replaces that single leaf and leaves the rest of the structure intact.
How are JSON arrays handled when merging?
Arrays are replaced, never joined. If JSON 1 has skills as ["JavaScript", "Python"] and JSON 2 has skills as ["React"], the merged value is ["React"]. Appending instead would quietly duplicate entries and change the meaning of an ordered list, so replacement keeps the output predictable. To combine two lists yourself, merge once and edit the array in the result.
What happens if one JSON input is invalid?
The merge is not run and no result is produced, so you can never mistake a broken document for a merged one. The offending input is named directly - for example JSON 3 contains invalid JSON - with the parser message and the line and column where parsing stopped. Nothing you typed is modified or cleared, so you can fix that one input and press Merge JSON again.
Does the later value also win when a key changes type?
Yes. If JSON 1 has value as an object and JSON 2 has value as a string, the merged value is the string. The same rule applies to every type change: object to array, array to object, number to string, boolean to number and null to a real value. Merging never guesses or coerces a type; the later document simply replaces what came before.
What happens to an input I added but left empty?
An empty input is skipped and counted in the result, so a blank JSON 4 never breaks the merge and never erases JSON 1 to JSON 3. The result panel reports how many empty inputs were skipped, which makes it obvious when a document you expected to contribute was in fact blank.
Is this JSON Merge Tool free?
Yes - free to use, with no sign-up, no account and no watermark. Every document is parsed and merged locally in your browser, so nothing is uploaded and your JSON is never stored on a server.