JSON Merger Tool

Merge two JSON objects free online. Choose shallow or deep merge, see exactly which keys were overwritten, and copy the combined result instantly.

Object A
Object B

How to Use This Tool

1
Paste both objectsAdd Object A and Object B into the two panels
2
Choose merge modeShallow replaces whole keys, deep merges nested fields
3
Merge and copyClick Merge, review the combined result, and copy it

Combining Two JSON Objects Sounds Simple Until Nesting Gets Involved

Merging {"a":1} with {"b":2} is trivial — the result is obviously {"a":1,"b":2}. The complexity starts when both objects have a nested object under the same key. A shallow merge would let the second object's entire nested object replace the first one, silently discarding fields the first nested object had. A deep merge instead looks inside and combines the nested fields, keeping what each side uniquely contributed.

This tool implements both behaviors explicitly so you can choose the one that matches your actual use case, since picking the wrong merge strategy is a common source of subtle configuration bugs.

Where Shallow Merge Is the Right Choice

When you genuinely want one object's settings to completely override another's nested settings — environment-specific config replacing a default block entirely rather than partially — shallow merge is correct. It is also simpler to reason about, since you know exactly which top-level keys came from which source.

Where Deep Merge Is the Right Choice

Configuration layering is the classic case: a base config object with sensible defaults, merged with a smaller override object that only specifies the handful of settings that differ for a specific environment. Deep merge lets the override supply just those few fields while everything else falls back to the base object's values, rather than requiring the override to repeat every setting.

Frequently Asked Questions

A shallow merge replaces entire top-level keys if they exist in both objects, even if the value is itself an object with sub-fields. A deep merge looks inside nested objects and merges their sub-fields individually, preserving fields from both sides that don't conflict.
The second object's value wins by default in a shallow merge. In a deep merge, this only applies to non-object values — if both values are objects, their inner fields get merged instead of one replacing the other entirely.
Configuration files often layer defaults with overrides — a base config merged with environment-specific settings. API responses sometimes need combining, like merging a user profile object with a separately fetched preferences object before sending to a frontend.
Arrays are replaced entirely rather than merged element by element, in both shallow and deep modes, since merging array contents could mean several different things depending on intent (concatenate, deduplicate, match by index) and guessing wrong would be worse than being explicit.
This tool merges two objects at a time. For three or more, merge the first two, then take that result and merge it with the third, repeating as needed.
–
(0)
Rate:
Comments

No comments yet

Be the first to share your experience with this tool!