Skip to main content
CalcChef

JSON Diff

Compare two JSON documents side by side or as a list of paths, such as $.name changed from "John" to "Jane". Key order is ignored; numbers compare exactly. How it works

Use the JSON Diff

Compares as you type. Objects are compared by key (order ignored), arrays by position, numbers by exact value (1.0 equals 1; digits beyond 15 are kept, not rounded). Duplicate keys: the last one wins. Up to 1,000,000 characters per side; larger inputs are compared in the background.

Differences

1 difference: 1 changed.
ChangePathAB
Changed$.name"John""Jane"

About the JSON Diff

Comparing {"name":"John","age":30} with {"name":"Jane","age":30} gives 1 difference: $.name changed from "John" to "Jane". Put the old document in A and the new one in B: removed means only in A, added means only in B. This JSON diff compares objects key by key, so key order does not matter, and arrays position by position, so [1,2,3] against [3,2,1] is 2 changes. Numbers are compared by exact value: 1.0 equals 1e0, while 12345678901234567890 and 12345678901234567891 differ. Tick Side by side to see both documents pretty-printed and lined up, with each changed line marked.

Example comparisons and the paths they report

JSON AJSON BSummaryDifferences
{"name":"John","age":30}{"name":"Jane","age":30}1 difference: 1 changed.changed $.name: "John" → "Jane"
{"a":1,"b":2}{"b":2,"a":1}No differences: the two documents are equal.(none)
[1,2,3][3,2,1]2 differences: 2 changed.changed $[0]: 1 → 3; changed $[2]: 3 → 1
{"user":{"tags":["a","b"]}}{"user":{"tags":["a"],"admin":true}}2 differences: 1 added, 1 removed.removed $.user.tags[1]: "b"; added $.user.admin: true
{"my key":1}{"my key":2}1 difference: 1 changed.changed $["my key"]: 1 → 2
{"a":{"b":1}}{"a":[1]}1 difference: 1 changed.changed $.a: {"b": 1} → [1]
{"x":1.0}{"x":1e0}No differences: the two documents are equal.(none)
{"id":12345678901234567890}{"id":12345678901234567891}1 difference: 1 changed.changed $.id: 12345678901234567890 → 12345678901234567891
{"a":1,"a":2}{"a":2}No differences: the two documents are equal.(none)

A path starts at $, the whole document: .key for a key, [n] for an array position counted from 0, and ["my key"] for a key that is not a plain name.

Frequently asked questions

Does JSON diff ignore the order of keys?
For objects, yes: {"a":1,"b":2} and {"b":2,"a":1} give “No differences: the two documents are equal.” Arrays are different, because their order is part of the data.
Why are two arrays with the same items reported as different?
Arrays are compared position by position. [1,2,3] against [3,2,1] reports $[0] changed from 1 to 3 and $[2] from 3 to 1; the middle item matches. There is no option to ignore array order or to match items by an id.
What happens if one side is not valid JSON?
The comparison waits and the message names the side, the line and the column. A trailing comma, as in {"a": 1,} written over three lines, gives JSON B is not valid JSON: Unexpected character "}" at line 3, column 1. Comments and unquoted keys are rejected the same way.
Can it compare very large numbers?
Yes. Numbers keep all their digits, so 12345678901234567890 and 12345678901234567891 are reported as changed. JavaScript’s JSON.parse would round both to the same value and call them equal.
What does it do with duplicate keys?
The last one wins, as in JSON.parse: {"a":1,"a":2} equals {"a":2}.
How large can the two documents be?
Up to 1,000,000 characters each, pasted or opened from a .json file. Above 60,000 characters in total the comparison runs in the background. The first 500 differences are listed, the counts cover all of them, and a value longer than 200 characters is cut in the list. The side-by-side view works up to 60,000 characters in total and shows the first 2,000 lines.

Related Tools

View all tools