Input (Array of JSON objects)

Merged Output

What Is JSON Merge?

Merging JSON means combining two or more objects into one. In a shallow merge, later objects overwrite earlier ones for keys that exist in both. In a deep merge, nested objects are merged recursively instead of being replaced. This is useful when merging config files, combining API responses, or building objects from defaults and overrides.

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

What if I have two separate objects, not an array?

Wrap them in an array: [{"a": 1}, {"b": 2}]. The tool expects an array of objects.

How are arrays handled?

In most merge implementations, arrays are replaced, not concatenated. If object A has "items": [1, 2] and object B has "items": [3], the result typically has "items": [3]. Check the tool's output to confirm.

Is my data sent anywhere?

No. Merging runs in your browser.

Can I merge config files?

Yes. Paste each config as an object in the array, with defaults first and overrides last. Deep merge is usually better for nested config structures.

What about duplicate keys in the same object?

JSON objects cannot have duplicate keys. If you have them, the parser will only keep one. Validate with the JSON Validator first.

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.