JSON Diff

[ DIFFERENCES ]
4
4 real · 0 formatting only
Added1
Removed0
Changed3
[ WHAT CHANGED ]
Changedsalarynumber
45000
+ 52000
Changedtags[1]string
"cebu"
+ "davao"
Type changedactiveboolean → string
true
+ "true"
Addedteamstring
+ "Finance"
A value changed TYPE, not just value — a number became a string, or something became null. That is usually the more serious kind of change, because the code reading it was not expecting it.
[ WHAT THIS IS ]

A text diff on JSON answers the wrong question. Change the indent, sort the keys, minify it — and a line diff reports that every line changed while the data is identical.

So the comparison is structural: both sides are parsed and the tree is walked by PATH. users[2].salary changed, wherever either sat in the file.

Key order is not a difference; array order is. That is the one judgement call here, and it follows what the two things actually are: a JSON object is an unordered set of members, an array is a sequence.

And 1.0 against 1 is the same number and a different document. It is listed separately — hiding it loses a real difference, calling it a change overstates one.

[ QUESTIONS ]

Why not just use a text diff?

Because a text diff on JSON answers the wrong question. Reformat a document — change the indent, sort the keys, minify it — and a line diff reports that every line changed while the data is identical. Swap two keys and it reports two deletions and two insertions when nothing changed at all. This compares the parsed structure by path, so it sees what actually differs.

Why is key order not a difference but array order is?

Because that is what the two things are. A JSON object is an unordered set of members, so {"a":1,"b":2} and {"b":2,"a":1} are the same object and any parser will hand your code the same result. An array is a sequence, so [1,2] and [2,1] are genuinely different. A differ that treats both the same is wrong in one direction or the other.

What does “same number, written differently” mean?

That one side has 1.0 where the other has 1, or 1e3 where the other has 1000. Those are the same number and a different document. Hiding it would lose a real difference between two files; calling it a change would make a reformat look like a data change. So it is listed separately and dimmed, and you can dismiss it at a glance.

Why is a type change called out separately?

Because it is usually the more serious kind. A number becoming a string, or a value becoming null, breaks the code reading it in a way a changed value does not — the consumer was not expecting a different shape. It is worth noticing before the changed values are.

What happens with duplicate keys?

Duplicate keys are legal JSON and every parser keeps the last one, so that is what gets compared — the value your code would actually see. The JSON Formatter reports duplicates if you want to find them.

Will very long numbers compare correctly?

Yes. Both sides are compared as they were written rather than through a floating-point value, so two 19-digit integers differing in the last place are still two different values. A differ using JSON.parse would round both to the same number and report no change.

[ THE MATHS ]
What counts as a difference
Different indent, or minifiedno
Different key orderno
Different array orderyes
1.0 against 1listed apart
A number became a stringtype change
[ WHY A TYPE CHANGE MATTERS MORE ]

A number becoming a string, or a value becoming null, breaks the code reading it in a way a changed value does not. The consumer was not expecting a different shape.

[ NEXT ]
43JSON FormatterTidy them before comparing, or find duplicate keys
48Text ComparisonWhen the bytes matter, not the data
63JSON ⇄ CSV ConverterThe same parser, pointed at a spreadsheet
72HTTP Status CodesFor the two responses you are comparing
[ IMPORTANT ]

Runs entirely in your browser; nothing is transmitted. This compares data, not text — indentation, key order and number formatting are invisible to it by design. Use Text Comparison when the bytes are what matter. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.