Developer Tools Runs in your browser Free · no account

JSON Merge

The JSON merge tool combines two documents into one. By default it merges recursively, so nested objects are joined rather than replaced wholesale, and where both documents set the same value the second wins. Arrays can be replaced, joined end to end, or joined with duplicates removed.

Options
Base JSON 0 characters
JSON to merge in 0 characters
Merged JSON

Your result will appear here.

Not sure where to start? Use Load example.

Results update automatically and are calculated on your device. Nothing you type is sent to a server.

Runs in your browser. Processing happens entirely in your browser. Nothing you enter is sent to Delimiter.live.

How to use the JSON Merge

  1. Paste the base document into the first box.
  2. Paste the document whose values should take priority into the second.
  3. Leave recursive merging on to combine nested objects; turn it off to replace top-level keys outright.
  4. Choose how arrays should behave, then copy or download the merged result.

Example

Input
{"a": 1, "b": {"x": 1}}
{"b": {"y": 2}}
Output
{
  "a": 1,
  "b": {
    "x": 1,
    "y": 2
  }
}

Common use cases

  • Applying an environment-specific override on top of a base configuration.
  • Combining a default settings file with a user’s customisations.
  • Merging two partial API fixtures into one complete test payload.
  • Layering a patch document over a manifest before deploying it.

Limitations and things to watch for

  • Where both documents set the same scalar value, the second always wins. There is no conflict prompt — use the JSON Diff tool first if you need to see what will be overwritten.
  • With recursive merging off, a nested object in the second document replaces the first one entirely rather than being combined with it.
  • Removing a key is not possible: merging only adds and overwrites. A null in the second document sets the value to null rather than deleting the key.

Frequently asked questions

Which document wins a conflict?
The second. Where both set the same key to a scalar value, the value from the second document is used. That makes the second document behave like an override layer over the first.
What is the difference between deep and shallow merging?
A deep merge combines nested objects key by key, so a nested object in the second document adds to rather than replaces the first. A shallow merge replaces whole top-level values, which is occasionally what you want for a clean override.
How should I handle arrays?
It depends on what the array means. Replace suits a complete list that the override should define outright. Join end to end suits an append-only list. Join with duplicates removed suits a set, such as a list of tags or regions.
Can I remove a key by merging?
No. Merging only adds and overwrites. Setting a key to null in the second document produces a null value rather than deleting the key.

Share this tool