JSON Merge – Deep Merge JSON Online
Deep merge two JSON documents privately in your browser. The right-hand value wins on conflicts.
Deep merge two JSON documents privately in your browser. The right-hand value wins on conflicts.
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.
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.
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.
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.
| Approach | Nested objects | Arrays | null on the right |
|---|---|---|---|
| This tool | Merged recursively | Replaced | Sets the value to null |
JavaScript spread / Object.assign | Replaced (shallow) | Replaced | Sets null |
| JSON Merge Patch (RFC 7386) | Merged recursively | Replaced | Deletes the key |
lodash _.merge | Merged recursively | Merged index by index | Sets null |
jq .[0] * .[1] | Merged recursively | Replaced | Sets null |
null or edit the left side.// comments must be cleaned first; check them in the JSON validator.en.json on the left and a partial fr.json on the right. The result holds every French string plus the English text for any key not translated yet, which is a quick way to preview a half-finished locale.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.
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.
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.
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.
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.
Keys from the left document come first in their original order; keys that exist only on the right are appended after them.
No. Both documents are parsed and merged in your browser, and nothing is sent to a server.