JSON Merge – Deep Merge JSON Online

Deep merge two JSON documents privately in your browser. The right-hand value wins on conflicts.

Deep merge JSON objects in your browser

JSON Merge combines two JSON documents into one result directly in your browser. Objects are merged recursively, so settings from both inputs are kept while a conflicting value from the right-hand document takes precedence. Arrays and primitive values are treated as complete values and are replaced by the right-hand input. The result is pretty-printed and neither input is modified.

That rule set makes the tool a good fit for layered configuration (a base file plus an environment override), for patching an API payload in a test fixture, and for checking what a framework's config loader will end up with after it merges your files.

How to merge JSON files

  1. Paste the base document into Left JSON.
  2. Paste the overriding document into Right JSON. Its values win wherever both sides set the same key.
  3. Click Merge. If either side is not valid JSON, the error appears under the output.
  4. Click Copy. For three or more files, paste the merged result back into the left panel and merge again with the next file.

Worked examples

1. Base config plus a production override

Left:

{"app":"api","db":{"host":"localhost","port":5432,"pool":{"min":1,"max":5}},"features":["search","export"],"debug":true}

Right:

{"db":{"host":"db.internal","pool":{"max":20}},"features":["search"],"debug":false}

Merged JSON:

{
  "app": "api",
  "db": {
    "host": "db.internal",
    "port": 5432,
    "pool": {
      "min": 1,
      "max": 20
    }
  },
  "features": [
    "search"
  ],
  "debug": false
}

db.port and pool.min survive from the left side because the right side never mentions them. features is replaced, not combined, so "export" is gone.

2. Null values and type changes

Left:

{"cache":{"ttl":60,"size":100},"proxy":"http://proxy:8080","owner":"team-a"}

Right:

{"cache":null,"proxy":{"url":"http://proxy:8080","timeout":5}}

Result:

{
  "cache": null,
  "proxy": {
    "url": "http://proxy:8080",
    "timeout": 5
  },
  "owner": "team-a"
}

cache becomes null rather than being deleted, and proxy switches from a string to an object because the right-hand value always wins when the types differ.

3. Two arrays

Merging [{"id":1},{"id":2}] with [{"id":3}] returns:

[
  {
    "id": 3
  }
]

To combine the records instead, join them in one array by hand, or on the command line run jq -s 'add' a.json b.json, then remove repeats with JSON Deduplicate.

How this deep merge compares

ApproachNested objectsArraysnull on the right
This toolMerged recursivelyReplacedSets the value to null
JavaScript spread / Object.assignReplaced (shallow)ReplacedSets null
JSON Merge Patch (RFC 7386)Merged recursivelyReplacedDeletes the key
lodash _.mergeMerged recursivelyMerged index by indexSets null
jq .[0] * .[1]Merged recursivelyReplacedSets null

Edge cases to watch

More places a deep merge helps

Related JSON tools

After merging, compare the left input with the result in the JSON diff checker to see exactly which keys the override changed. Use the JSON sorter to give the merged config a stable key order before committing it, and the YAML to JSON converter when your config layers are written in YAML.

FAQ

How do I merge two JSON files?

Open each file, paste the base file into Left JSON and the overriding file into Right JSON, then click Merge. To merge more than two files, paste the result back into the left panel and add the next file on the right.

Does it concatenate arrays?

No. An array is treated as a single value, so the right-hand array replaces the left one completely. Two top-level arrays therefore return just the right array.

Which value wins on a conflict?

The right-hand value, at whatever depth the conflict occurs. Where both sides hold an object, the two objects are merged key by key instead.

Does null delete a key?

No. A null on the right is copied into the result as null. That differs from JSON Merge Patch (RFC 7386), where null removes the key.

What order are keys in the result?

Keys from the left document come first in their original order; keys that exist only on the right are appended after them.

Is my JSON uploaded?

No. Both documents are parsed and merged in your browser, and nothing is sent to a server.