Input (Array of JSON objects)

Merged Output

What Is JSON Merge?

You've got a default.json config and a production.json that overrides just a handful of settings. You need a single merged result. That's exactly what this tool is for. Merging JSON means combining two or more JSON objects into one. In a shallow merge, later objects overwrite earlier ones for any key they share. In a deep merge (following patterns like Object.assign), nested objects are combined recursively instead of being replaced wholesale — so you keep both the default nested keys and the overridden ones.

This tool expects a JSON array of objects. It merges them in order using either shallow or deep mode. The result is a single object. Processing runs in your browser.

How to Use This Tool

1

Enter JSON Array

Paste a JSON array of objects, e.g. [{"a": 1}, {"b": 2}, {"a": 3}]. The order matters: later objects override earlier ones for conflicting keys. Use Deep or Shallow to choose merge behavior.

2

Check the Output

The right panel shows the merged object. In shallow mode, {"a": 1, "b": 2} merged with {"a": 3} gives {"a": 3, "b": 2}. In deep mode, nested objects are merged recursively.

3

Copy or Download

Use Copy or Download to get the result. For formatting, use the JSON Formatter. For validation, use the JSON Validator.

Where JSON Merge Helps

Merging config files is a common use case. You have default.json and production.json; you want to merge them so production overrides only the keys it needs. Deep merge combines nested defaults recursively. For API responses from multiple sources, or when building objects from a base template with environment-specific overrides, merge gives you a single combined object. The JSON Formatter helps format the result for readability.

JSON Merge Examples

Here is an example of merging two subscriber config objects. Later objects override earlier ones for conflicting keys.

Example: Merging subscriber configs

Input (array of objects to merge):

Input

Merged output:

Output

Shallow vs Deep Merge

Shallow merge: if both objects have a key, the value from the later object replaces the earlier one entirely. Nested objects are not merged; they're replaced. Deep merge: nested objects are merged recursively. So {"a": {"b": 1}} merged with {"a": {"c": 2}} gives {"a": {"b": 1, "c": 2}} in deep mode, but {"a": {"c": 2}} in shallow mode. JavaScript's Object.assign does a shallow merge. Libraries like Lodash merge do deep merges.

The JSON specification defines objects as unordered collections of key-value pairs. Merge order matters: later values override earlier ones. For API responses from Postman or fetch, merging configs or combining defaults with overrides is common. The formal standard is RFC 8259. MDN's JSON guide covers parsing and stringifying.

Frequently Asked Questions

How do I merge two JSON objects in JavaScript?

For a shallow merge, use the spread operator: {...objA, ...objB} or Object.assign({}, objA, objB). For a deep merge, use a library like Lodash _.merge(). This tool handles both cases without any code.

What is the difference between deep merge and shallow merge?

In a shallow merge, if both objects have the same key, the value from the later object replaces the earlier one entirely — including nested objects. In a deep merge, nested objects are merged recursively. So {"a": {"b": 1}} deep-merged with {"a": {"c": 2}} gives {"a": {"b": 1, "c": 2}} — both keys survive.

How do I merge JSON config files with overrides?

Paste your configs as a JSON array with defaults first and overrides last: [defaultConfig, productionConfig]. Use deep merge if your configs have nested objects — it will preserve the default nested keys while applying just the overrides.

How are arrays inside JSON objects handled during merge?

Arrays are replaced, not concatenated. If object A has "items": [1, 2] and object B has "items": [3], the result has "items": [3]. If you need array concatenation, you'd need to handle that in code.

Is my data sent to a server?

No. Merging runs entirely in your browser. Your JSON never leaves your device.

Related Tools

For JSON syntax, see json.org and RFC 8259. For merging in JavaScript, see MDN Object.assign and spread syntax. For deep merge in Lodash, see the merge function. For MDN JSON overview. See also jq and Postman.