Hunt
Skip to content

JSON Diff

Paste two JSON documents to see exactly how they differ: values only in one of them, and values that are different in both, each with its path. Key order and formatting are ignored, so only real differences in the data are shown.

Runs in your browser

Document A

Document B

Differences

Paste JSON on both sides to compare them.

What this tool does

A text diff of two JSON files is noisy: reordered keys, different indentation and 1.0 versus 1 all show up as changes, while the one value that matters is easy to miss. This tool compares the data instead. It walks both documents and lists each value that exists in only one of them or differs between them, with its JSONPath.

The comparison runs in your browser, so you can compare real API responses or configuration files without uploading them.

How to use the JSON Diff

  1. Paste one JSON document as A and the other as B, or press Sample.
  2. The differences appear below as you type, with a summary of how many values are only in A, only in B, or different.
  3. Select a difference to see it in document A or B.
  4. Turn on Ignore array order to compare lists without regard to order, or copy the result as a JSON Patch.

Examples

A different value and a key only in B

Input
a: {"id":7,"price":19.9}
b: {"price":21,"id":7,"tags":["sale"]}
Output
[
{
"op": "replace",
"path": "/price",
"value": 21
},
{
"op": "add",
"path": "/tags",
"value": [
"sale"
]
}
]

The keys are in a different order too, but that isn't reported. The differences list shows $.price as different (19.9 in A, 21 in B) and $.tags as only in B.

Equivalent values are not differences

Input
a: {"total":10.50,"name":"café"}
b: {"name":"café","total":10.5}
Output
[]

10.50 and 10.5 are the same number, and the escaped and plain é are the same string, so the documents are equal.

Array items only in A

Input
a: {"steps":["build","test","lint","deploy"]}
b: {"steps":["build","test"]}
Output
[
{
"op": "remove",
"path": "/steps/3"
},
{
"op": "remove",
"path": "/steps/2"
}
]

The patch removes the highest index first, so each operation still points at the right item when the patch is applied in order.

How values are compared

  • Objects are compared key by key; the order of keys doesn't matter.
  • Numbers are compared by value, exactly: 1.0, 1 and 1e0 are equal, and two large IDs that differ only in the last digit are still reported as different.
  • Strings are compared after decoding escapes, so "caf\u00e9" equals "café".
  • Arrays are compared position by position. With Ignore array order on, they are compared as unordered collections: matching items pair up, and the rest are listed as only in A or only in B.
  • A value with a different type in each document, for example a number in A and a string in B, is reported as different, with both types shown.

JSON Patch output

Copy JSON Patch (A → B) gives the differences as an RFC 6902 patch: a list of add, remove and replace operations that turns document A into document B. Use Swap to get the patch from B to A. Many libraries can apply it, which makes it useful for sending changes to an API (PATCH requests), storing an audit log or writing tests. Values in the patch are copied from your JSON exactly.

Options

Ignore array order
Compares arrays as unordered collections, useful for lists of tags, IDs or permissions. An item that differs appears once as only in A and once as only in B, because without order there is nothing to pair it with.

Limitations

  • Arrays are compared by position by default: an item inserted at the start makes every later item different. Turn on Ignore array order for lists where order doesn't matter.
  • With duplicate keys in an object, the last value is used, as JSON.parse does.
  • Strict JSON only on both sides. To repair invalid JSON first, use the JSON Fixer.
  • Inputs up to 10 MB each are supported. The comparison runs in your browser.

Frequently asked questions

Is my JSON sent to a server?

No. Both documents are compared entirely in your browser. Nothing you paste is uploaded, stored or logged.

How is this different from a text diff?

A text diff compares lines, so reordered keys or different indentation look like changes. This tool compares the data, so it only reports values that are actually different, and it tells you the path of each one.

Why is `1.0` equal to `1`?

In JSON they are the same number written two ways. The comparison works on values, exactly, without converting to floating point, so it also catches large numbers that differ only in the last digit.

What is a JSON Patch?

A standard format (RFC 6902) that describes changes to a JSON document as a list of operations such as {"op": "replace", "path": "/price", "value": 21}. Applying the generated patch to document A produces document B.