JSON Merger
Deep merge two JSON objects with conflict highlighting in the result
About JSON Merger
JSON Merger performs a deep merge of two JSON objects, combining keys from both documents. When the same key exists in both objects, the second value overwrites the first (for primitives) or merges recursively (for objects). This mirrors how tools like lodash.merge and Object.assign work, letting you preview the result before writing code.
- ✓Deep merge — nested objects are merged recursively, not overwritten entirely
- ✓Highlights conflicting keys where the second object overrides the first
- ✓Handles arrays, primitives, and nested objects at any depth
- ✓Shows the merged result as formatted JSON ready to copy or download
How Deep Merging Works — and Where Conflicts Come From
Merging two JSON documents sounds simple until both sides define the same key. A shallow merge (what Object.assign or the JavaScript spread operator does) replaces the entire value of any shared key, so a nested settings object from the left side is thrown away even if the right side only changed one field inside it. A deep merge walks into nested objects and combines them key by key, which is almost always what you want for configuration files and API payloads.
The rules this tool follows
- ·Keys that exist on only one side are copied into the result unchanged
- ·When both sides contain an object under the same key, the tool recurses into it and merges those objects the same way
- ·When both sides contain a different non-object value (a string, number, boolean, null or array), the right-hand value wins and the path is reported as a conflict
- ·Arrays are treated as single values: the right-hand array replaces the left-hand one rather than being concatenated
A worked example
// Left (base config)
{ "server": { "port": 8080, "host": "localhost" }, "features": ["search"] }
// Right (production overrides)
{ "server": { "port": 443 }, "features": ["search", "billing"], "debug": false }
// Result
{
"server": { "port": 443, "host": "localhost" },
"features": ["search", "billing"],
"debug": false
}Here server.port and features are listed as conflicts so you can confirm the right-hand values are the ones you meant to keep. server.host survives because the right side never mentioned it, and debug is added because it only exists on the right.
Why arrays are replaced, not combined
There is no single correct way to merge two arrays. Concatenating ["a"] and ["a", "b"] gives a duplicate; merging by index can pair up unrelated items; merging by an id field requires knowing which field identifies an item. Replacement is the predictable choice, and it matches how most configuration systems (and libraries such as Helm values files) treat lists. If you need a combined list, merge the documents first and then edit the array in the result.
Common uses
- ·Layering environment-specific overrides on top of a base configuration file
- ·Applying a partial update (a patch-like object) to a full record before saving it
- ·Combining translation or locale files where newer keys should take precedence
- ·Checking what an override file actually changes, using the conflict list as a quick diff
Tip: Put the document you want to take precedence on the right. If you need the opposite priority, swap the two inputs rather than editing values by hand.