Search DevTools

Jump to any tool or page

Merge Multiple JSONs

Combine any number of JSON documents into one with shallow, deep, or array-concatenating merge strategies.

Documents

2 total · 0 filled
Document 1
Document 2

Merged output

Paste two or more JSON documents and hit Merge.

About merging JSON documents

Merging JSON sounds trivial until two documents disagree. This tool combines any number of JSON documents in order, left to right, and lets you pick exactly how collisions resolve. Everything runs in your browser — nothing is uploaded.

Merge strategies

  • Shallow – only top-level keys are considered, exactly like Object.assign or object spread. A later document’s config object replaces the earlier one wholesale, losing every nested key the earlier copy had.
  • Deep – plain objects are merged recursively at every level, so nested keys survive unless the later document defines that exact path. Anything that is not a plain object — a string, number, boolean, array, or null — overwrites whatever sat there before.
  • Concat arrays – a deep merge that appends arrays at the same path instead of replacing them.

Why arrays are ambiguous. There is no correct default. Replacing the array treats it as an atomic value; concatenating treats it as a bag of items and happily produces duplicates; merging by index assumes the two arrays describe the same positional slots, which is almost never true for lists of records. Libraries disagree here, which is why the choice is a visible toggle rather than a hidden assumption.

null is a value, not an absence. JSON has no undefined, so a key set to null overwrites the earlier value rather than leaving it alone. If you need “delete this key” semantics, you want JSON Merge Patch (RFC 7386), where null means removal, or JSON Patch (RFC 6902) for explicit, ordered operations.

Duplicate keys inside one document are resolved before this tool ever sees them: JSON.parse keeps the last occurrence and silently drops the rest, so a document with two id keys parses without complaint.

Prototype pollution. Deep-merging untrusted JSON is a real attack path: a payload carrying __proto__, constructor, or prototype can write onto Object.prototype and change behaviour for every object in the process. This merger skips those keys outright and builds results with null-prototype-safe assignment.

Tip: the conflict list below the output shows every path where a later document overwrote an earlier value — the fastest way to spot an accidental override in a stack of config layers.

Data Transformation

About Merge Multiple JSONs

Combine several JSON documents into one, choosing how collisions resolve: shallow overwrite, recursive deep merge, or deep merge with arrays concatenated. Merging is where the ambiguity lives, so the tool reports which key paths actually collided rather than silently picking a winner.

Frequently asked questions

What is the difference between shallow and deep merge?
A shallow merge copies top-level keys only, so if two documents both define a config object, the later one replaces the earlier entirely and every nested key inside the first is lost. A deep merge recurses into matching objects and combines them key by key, so nested settings from both survive unless they collide at the same leaf. Shallow is what Object.assign and the spread operator do, which surprises people expecting nested values to be preserved.
Why do arrays need their own strategy?
Because there is no single correct answer for combining them. Given [1,2] and [3], a merge could reasonably produce [3] (replace), [1,2,3] (concatenate), or [3,2] (index-wise overwrite), and each is right for some data. Replacement suits a list that represents one complete setting; concatenation suits an accumulating collection. This tool offers replace and concatenate explicitly rather than guessing, because a wrong guess here corrupts data quietly.
How is null treated?
As a real value that overwrites, because in JSON it is one. This differs from JavaScript merge helpers that skip undefined, since undefined cannot appear in JSON at all. If a later document sets a key to null, the merged result has null there rather than falling back to the earlier value, which is usually what an explicit null in a config override is meant to express.
Is merging untrusted JSON safe?
Only if the merge guards against prototype pollution. A payload containing a __proto__ key can, in a naive recursive merge, write onto Object.prototype and affect every object in the running program, which is a well-known route to privilege escalation and denial of service in Node services. This tool skips __proto__, constructor, and prototype keys while merging. If you implement your own merge for server-side use, add the same guard or use a null-prototype object.
When should I use JSON Merge Patch instead?
When you are describing a change to a document rather than combining two peers. RFC 7386 defines exactly this: an object of the same shape where each value replaces the target's, and null means delete the key. It is the right model for PATCH request bodies. Its deliberate limitation is that it cannot set a value to null and cannot patch inside arrays, so for those cases JSON Patch (RFC 6902) with its explicit operation list is the better fit.