Deep merge two JSON objects — base config plus overrides

Paste a base JSON document and a second one with overrides, and the tool merges them at every level, lets you pick how arrays combine and which side wins, and lists every value that clashed.

Live demo · real result from this tool
On conflict keep

Merged JSON

{  "name": "api",  "server": {    "port": 9090,    "host": "0.0.0.0",    "tls": true  },  "features": [    "search"  ],  "debug": false}

2 conflicting values

PathFirstSecondKept
server.port80809090second
features["auth"]["search"]second

Processed on your device — nothing is uploaded.

How to use the JSON merger

  1. Paste the base document into First JSON (base).
  2. Paste the overrides into Second JSON (overrides).
  3. Choose how Arrays combine: Replace, Concatenate, Concatenate without duplicates or Merge item by item.
  4. Choose which side On conflict keep: Second (the default) or First.
  5. Pick an Indent and copy the Merged JSON. A table below lists each conflicting value and which one was kept.

What it does and when to use it

Layered configuration is common: a default.json with every setting, then a production.json that changes a few. Libraries such as node-config, Spring profiles and Helm values files all merge this way. This tool shows what the final, merged config will look like before you deploy, and the conflict table tells you exactly which settings the override file changes.

It also helps when you combine two partial API responses, add new translation keys to an existing language file, or check what a “deep merge” call in your code will produce. Set On conflict keep to First to fill in only missing keys without touching existing values.

To see what differs between two documents without merging them, use JSON diff. After merging, sort the keys with the JSON key sorter or validate the result with the JSON Schema validator.

How it works

Both documents are parsed in your browser. The merge starts from a copy of the first. For each key in the second: if the key is new, it is added; if both values are objects, they are merged the same way, one level down; if both are arrays, your array option decides; otherwise, if the values differ, it is a conflict and the side you chose wins. Key order follows the first document, with new keys from the second added at the end of each object. Duplicate checks for arrays compare items by their JSON text, so {"a":1} and {"a":1} count as equal.

Worked examples

The default sample, merged with the second document winning:

{"name":"api","server":{"port":9090,"host":"0.0.0.0","tls":true},"features":["search"],"debug":false}
Path        | First    | Second     | Kept
server.port | 8080     | 9090       | second
features    | ["auth"] | ["search"] | second

host survives from the base, tls and debug are added, and the features list is replaced.

Merge item by item on worker settings: base [{"name":"a","threads":2},{"name":"b","threads":2}], override [{"threads":8}] gives [{"name":"a","threads":8},{"name":"b","threads":2}].

Limits and tips

  • Item-by-item merging pairs by position, not by an id field. If the lists are in a different order, the wrong items are merged.
  • Merging is two-way only; there is no three-way merge with a common ancestor, as Git does.

Frequently asked questions

Does a null in the second document delete the key?
No. null is treated as an ordinary value, so it replaces the first value and is listed as a conflict. This differs from JSON Merge Patch, where null means "remove this key". To remove a key, delete it from the merged result by hand.
Which array option should I choose?
Replace (the default) suits config overrides, where the second list should win completely. Concatenate keeps both lists in order, duplicates included. Concatenate without duplicates appends only items not already present, comparing whole items. Merge item by item pairs items by position and deep-merges each pair, which suits lists of settings in a fixed order.
What counts as a conflict?
Any place where both documents have a value at the same path and the values differ and cannot be merged deeper, such as two different numbers, a string against an object, or two arrays under Replace. Identical values are not reported. Keys that exist in only one document are simply added.
Can I merge more than two files?
Merge two, then paste the result into the first box and the next file into the second. Each step keeps the same rules, so later files override earlier ones.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close