Data ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Data Tools

JSON Merge Tool: Deep Merge Two JSON Files

Merge two or more JSON documents with deep merge, shallow merge or RFC 7396 Merge Patch, choose how arrays combine, and see every path that was overwritten.

View all tools
ResultUpdates as you type
{
  "name": "my-app",
  "version": "1.1.0",
  "features": [
    "export"
  ],
  "database": {
    "host": "db.internal",
    "port": 5432,
    "ssl": true
  }
}

Merged 2 documents. Later documents overwrote or removed 3 different values: $.version, $.features, $.database.host.

How to use JSON Merge Tool: Deep Merge Two JSON Files

Paste the base JSON into A and the overriding JSON into B; the merged result appears as you type. Choose a merge mode and how arrays should combine, then press Copy result. Separate extra documents in A with a line of ---.

  1. Paste JSON A and BPut the base document in JSON A and the overrides in JSON B. Add more documents to A separated by a --- line.
  2. Choose merge mode and arraysPick Deep, Shallow or JSON Merge Patch, and whether arrays are replaced, joined, de-duplicated or merged by index.
  3. Check conflicts and copyRead the note listing overwritten paths such as $.version, then press Copy result.

Deep merge with an example

In the sample, A has "database": {"host": "localhost", "port": 5432} and B has "database": {"host": "db.internal", "ssl": true}. A deep merge gives {"host": "db.internal", "port": 5432, "ssl": true}: when both sides hold an object, their keys are merged level by level; otherwise B's value wins, so version changes from 1.0.0 to 1.1.0. The note lists every overwritten path, here $.version, $.features and $.database.host. A shallow merge only combines the top level, so B's database object replaces A's entirely and port is lost.

Arrays, null and JSON Merge Patch

By default B's array replaces A's. Concatenate (A first) joins them, so ["login", "search"] and ["export"] become ["login", "search", "export"]; Concatenate without duplicates skips items already present, comparing objects by content; Merge item by item merges elements at the same index. In deep and shallow mode a null in B simply overwrites the old value. JSON Merge Patch follows RFC 7396 instead: null deletes the key and arrays are always replaced whole, as with HTTP PATCH requests sent as application/merge-patch+json. To merge three or more files, separate them in A with a line containing only ---; they are applied in order, later ones winning.

Accuracy and data handling

Keep the original data and spot-check fields, types and delimiters before using an important conversion. The calculation runs in your current browser; the tool code does not send the input to a processing API.

FAQ

Which value wins when both JSON files have the same key?

B's value. If both values are objects, deep merge combines their keys instead; arrays follow the option you chose; anything else from B replaces A's value.

Can I merge more than two JSON files?

Yes. Put several documents in A separated by a line containing only ---, plus one in B. They are merged in order and later documents override earlier ones.

How do I delete a key while merging?

Choose JSON Merge Patch (RFC 7396, null deletes) and set that key to null in B. In deep or shallow mode null is kept as an ordinary value instead.

What is the difference between JSON merge and JSON diff?

Merging layers one document on another to produce a new combined JSON. A diff compares two documents and lists what was added, removed or changed without producing a merged result.

More Data Tools

Related tools