Skip to content
{}

JSON Merge

Deep-merge two JSON documents with the second overriding the first, key by key.

0 chars | 1 lines
0 chars | 1 lines
0 chars | 0 lines

Conversion payloads stay in this browser tab and are never placed in page URLs - see how local processing works. Privacy-safe analytics record only the tool, outcome, and a coarse input-size bucket.

How to Merge JSON

Paste a base document on the left and an override on the right. Every key present in the override is applied over the base; keys only in the base survive untouched. This is the environment-overlay pattern used by Kubernetes kustomize, Helm values files, and layered application configuration.

Merge Rules

The complete rule set, with no special cases.

InputOutputNote
{"a":1} + {"b":2}{"a":1,"b":2}Keys combine
{"a":1} + {"a":2}{"a":2}Override wins
{"a":{"x":1}} + {"a":{"y":2}}{"a":{"x":1,"y":2}}Objects merge deeply
{"a":[1,2]} + {"a":[3]}{"a":[3]}Arrays replace
{"a":1} + {"a":null}{"a":null}null is a value, not a delete

Frequently Asked Questions

How are conflicts resolved?

The second document wins. Objects are merged recursively key by key, so a nested override only replaces the keys it names and leaves its siblings intact.

Are arrays concatenated or replaced?

Replaced. Concatenation is the more surprising behaviour: merging a base config with itself would silently double every list. If you need both sets of items, merge the arrays deliberately rather than relying on a merge rule.

What if one side is not an object?

The second document replaces the first outright and the output notes that this happened, so a mismatch between an object and an array or scalar is visible rather than hidden.

Is this the same as a JSON Merge Patch?

It is close to RFC 7386 for objects, with one deliberate difference: a null in the override is stored as null instead of deleting the key. Deletion by null surprises people using this to layer configuration, so the tool keeps the value you can see.

Related Tools