Deep merge JSON objects
online, free & instant
Combine two JSON objects with a recursive deep merge. Override individual keys, layer environment configs, and inspect the result — entirely in your browser with no server involved.
Open JSON Merge ToolMerge JSON configs in three steps
Private, fast, and dependency-free.
No Server
Your JSON configs never leave your device. There is no backend to send them to.
Deep Merge
Nested objects are merged recursively — not replaced shallowly — just like lodash.merge.
Diff Preview
Use the built-in Diff tab to preview exactly what changes before applying the merge.
Related JSON tools
Common questions answered
What is a deep merge of JSON objects?
A deep merge recursively combines two JSON objects. When both objects share a key whose value is itself an object, those nested objects are merged too — rather than one replacing the other as in a shallow merge.
How does merging handle conflicting keys?
For scalar values (strings, numbers, booleans), the second object's value wins. For nested objects, the keys are merged recursively. Arrays are replaced by default — the second array takes precedence.
Is my JSON data sent to a server?
No. All processing runs in your browser. Your JSON is never uploaded, logged, or stored.
Can I merge more than two JSON objects?
Yes. You can chain merges — format and merge a base object, then merge the result with a third object, and so on.
What is a common use case for merging JSON?
Merging configuration files is the most common use case — for example combining a default config with an environment-specific override, where the override wins on any shared keys.
What is JSON merging?
JSON merging combines two or more JSON objects into a single unified object. When objects share keys, the merge strategy determines which value wins. A shallow merge replaces top-level keys. A deep merge recursively combines nested objects, only replacing leaf values that differ. Understanding the difference is critical when merging configuration files or state objects.
This tool performs deep merging by default: nested objects are combined recursively, arrays can be concatenated or replaced, and conflicting primitive values use the rightmost input. This is particularly useful for combining partial configuration overrides with a base config, or assembling a complete object from multiple API responses.
// Object A
{"db":{"host":"localhost","port":5432}}
// Object B
{"db":{"port":3306,"ssl":true}}
{
"db": {
"host": "localhost",
"port": 3306,
"ssl": true
}
}
Get the most out of this tool
- Use deep merge for configuration files — it preserves base settings while applying overrides for specific environments.
- Order matters: the rightmost object values win when keys conflict, so put your overrides last.
- When merging arrays, decide whether to concatenate or replace — the right choice depends on your data semantics.
JSON merging strategies explained
Merging JSON objects is a fundamental operation in configuration management, API development, and data processing. The most common merge strategy is "last-write wins" shallow merge: Object.assign() in JavaScript, or {**obj1, **obj2} in Python. With this strategy, keys from the second object overwrite the same keys from the first object, and keys unique to each object are included in the result. Nested objects are replaced entirely rather than merged recursively.
Deep merge (recursive merge) handles nested objects differently. When both objects have the same key and both values are objects, a deep merge recurses into them and merges their contents. The result is a fully merged tree where nested structures are combined rather than replaced. This is the behavior most users expect when merging configuration objects — "I want the defaults from object A but override only the specific settings in object B, not replace entire nested sections."
Array merge strategy is the most contentious decision in JSON merging. Concatenation combines both arrays: [1,2] + [3,4] = [1,2,3,4]. Replacement uses the second array entirely: [1,2] replaced by [3,4] = [3,4]. Union produces the set of unique elements. Patch merging (RFC 7396 JSON Merge Patch) replaces arrays entirely — if you specify an array in the patch, it replaces the array in the target. Choose the strategy based on your specific use case.
Configuration layering is the most common use case for JSON merging in production systems. Applications typically have a base configuration (defaults), an environment configuration (staging, production), and an instance configuration (per-server overrides). These are merged in order — later layers override earlier ones. This pattern is used by tools like Webpack (with merge()), Kubernetes (with strategic merge patches), and Docker Compose (with multiple config files).
JSON Merge Patch (RFC 7396) is a standardized merge format for REST APIs. A PATCH request sends a partial JSON document where keys with values replace corresponding keys in the resource, and keys with null values delete the corresponding key. This enables partial updates without sending the entire resource. For example, patching {"email": "new@example.com", "phone": null} updates the email and removes the phone field, leaving all other fields unchanged.
Conflict resolution is relevant when merging independent modifications. If two developers each modify the same JSON configuration key to different values, a merge must decide which value wins. Tool-based merges typically use "last-write wins" or prompt for manual resolution. JSON Patch (RFC 6902) supports a "test" operation that validates the current value before applying changes — useful for optimistic concurrency control in collaborative JSON editing.
When developers use this tool
Additional frequently asked questions
What is the difference between shallow merge and deep merge?
Shallow merge: if both objects have the same key and the value is an object, the second object's value entirely replaces the first's — nested content is not merged. Deep merge: if both have the same key and both values are objects, they are recursively merged. Deep merge is what most users intuitively expect when combining configuration objects with nested settings.
Can I merge more than two JSON objects?
Yes. Multiple JSON objects can be merged sequentially — merge A and B to get AB, then merge AB and C to get ABC. This is equivalent to merging all three with a left-to-right reduce operation. The final result contains all keys, with later objects overriding earlier ones for duplicate keys.
What is JSON Merge Patch and how is it different from JSON Patch?
JSON Merge Patch (RFC 7396) is a simple format where you send a partial document as a PATCH body — non-null values replace, null values delete. JSON Patch (RFC 6902) is an explicit operation list (add, remove, replace, move, copy, test) with exact paths. Merge Patch is simpler but less precise; JSON Patch is more powerful and supports atomic conditional operations.
How should arrays be handled during a merge?
There is no universally correct answer — it depends on your use case. RFC 7396 JSON Merge Patch replaces arrays entirely (the patch array wins). Deep mergers often concatenate or deduplicate arrays. For configuration merging, replacement is usually more predictable. For data aggregation, concatenation makes more sense. Choose explicitly and document your merge strategy.