Merge JSON Online

Merge two or more JSON documents into one: paste them in, or just drop in several .json files. Supports deep merge (nested objects recursed level by level), shallow merge and array concatenation. When keys collide you pick which side wins, and the page lists every single field that got overwritten. Everything runs locally in your browser; no data is uploaded.
Drop one or more .json files here

You can also click this area to pick files — each file becomes one input block below

Merge mode
Array fields
On conflict
Other
Merge result
Waiting to merge
Notes:
1. Merging goes top to bottom: block 1 is merged with block 2, that result is merged with block 3, and so on. Order decides who overwrites whom.
2. Deep merge only recurses into keys where both sides are objects. As soon as one side is not an object (a number, string, array or null), the rules above pick one of them directly — it never guesses.
3. Arrays are replaced wholesale by default rather than merged index by index — index-wise merging is almost always wrong; see the article below.
4. "Array concat" mode ignores the object options above: every input is concatenated into one array. Inputs that are themselves arrays are flattened one level; anything else goes in as a single element.
5. Dropped files are never uploaded — they are only read as text inside the browser.

About merging JSON

How deep merge differs from shallow merge

Shallow merge only looks at top-level keys: when both documents have the same top-level key, the later one replaces the earlier one wholesale, even if its value is an object twenty levels deep. Deep merge keeps descending as long as both sides are objects, and only overwrites the leaf that genuinely conflicts. Config files almost always want a deep merge — take a set of defaults plus a three-line environment override, and a shallow merge wipes out every other key in that same group, which is exactly where "I changed one line and the whole block disappeared" comes from. Conversely, if the two documents are peer records to begin with, shallow merge is faster and easier to predict.

Why arrays are replaced wholesale by default

Because merging by index is almost always wrong. An array index is not an identity: merging ["a","b","c"] and ["x"] by position gives you ["x","b","c"], which is essentially never what anyone wanted — whoever supplied ["x"] probably meant "this one item is the whole list." JSON Merge Patch (RFC 7386) says the same thing: an array is handled as one whole value, never merged element by element. So this page defaults to "later one wins" while still offering "concatenate" and "concatenate, then dedupe", because stitching a few lists together really is another common need — it just is not the same job as overriding config, so you have to pick once.

Is null a deletion or a value?

This is where merging goes wrong most often. {"a": null} could mean "set a to empty" or "leave a alone", and JSON itself never says which. RFC 7386 treats null as a delete instruction, while most "deep merge" libraries treat it as an ordinary value and overwrite as usual. Both are defensible; the mistake is leaving the default unstated. This page defaults to not letting null overwrite an existing value, because in config merging that is closer to what people mean. When you do want null to clear a field explicitly, tick "Let null overwrite an existing value".

Check that every input is valid JSON before merging

The error a merge tool reports is often not a merge problem at all — one of the inputs simply does not parse: a trailing comma, single quotes, comments carried over from source code. This page marks the parse result and error position under each input block separately, so fix the red one before merging. If an input is long and you need to see its structure or jump to a specific line, opening it in JSON Formatter Online and expanding the tree beats counting brackets in a textarea.

FAQ

How do I merge two JSON files into one?

Drop both .json files into the dashed box above; each becomes its own input block, then click "Merge". You can also paste the contents straight into two textareas. Merging goes top to bottom, so whichever block sits lower has the final say on a conflict.

Can I merge more than two JSON documents at once?

Yes, as many as you like. Click "Add a JSON block" for another textarea, or drop several files at once. Merging happens pairwise in order: the result of block 1 and block 2 is then merged with block 3, and so on — equivalent to layering overrides in sequence.

Which value is kept when two keys have the same name?

By default "later overwrites earlier", so the block further down wins — which matches the usual "defaults plus environment override" pattern. You can switch to "earlier one is kept", in which case only keys that had not appeared before get filled in. Either way, every overwritten field is listed one by one above the result.

Will a deeply nested object be replaced as a whole?

Not if you pick "deep merge". Deep merge keeps recursing while both sides are objects and only overwrites the leaf fields that actually conflict, leaving everything else intact. "Shallow merge" compares top-level keys only, so a top-level key with the same name is replaced wholesale — both behaviours are useful; see "How deep merge differs from shallow merge" above.

Are arrays concatenated or overwritten?

Overwritten by default; change it under "Array fields" to "concatenate" or "concatenate, then dedupe". Deduplication compares by value, and objects and arrays are deduplicated too (identical content counts as a duplicate), not just strings and numbers. To join several JSON documents straight into one big array, the "array concat" mode at the top is more direct.

Will a field whose value is null overwrite the original value?

Not by default — this page treats null as "this item is not supplied" and skips it. It only overwrites once you tick "Let null overwrite an existing value". Both behaviours exist in different libraries, so this page makes it an explicit switch instead of picking one for you.

What do I do when it says a parse failed?

Each input block shows its own parse status and error position, so first see which one turned red. The usual causes are a trailing comma, single quotes, a // comment, or True, None, undefined and other literals that JSON does not accept, copied over from source code.

Is my JSON uploaded to a server?

No. Reading files, parsing, merging and output all happen locally in the browser with JavaScript — this site has no backend that could receive the content. Merging live config, API responses or environment files containing secrets carries no risk of leaking them, and the page keeps working with the network disconnected.