How to Compare Two JSON Files
Comparing two JSON payloads by eye is error-prone — a reordered key or different indentation looks like a change when the data is identical. A structural diff compares the meaning, not the text. Here's how to read one.
Structural, not textual
A JSON diff parses both documents and compares them by key and index. That means whitespace, indentation, and key order never register as differences — only the data does:
{ "b": 2, "a": 1 }
is equal to { "a": 1, "b": 2 }, even though the text differs.
Three kinds of change
Every difference is reported by its path and falls into one of three types:
- Added — the key or index exists only in the right (changed) document.
- Removed — it exists only in the left (original) document.
- Changed — both have it, but the value or type differs.
A path like $.roles[1] points straight at the second element of the roles array, so you can find it instantly in the source.
Arrays compare by position
Array elements are matched index by index. Inserting an item near the front shifts everything after it, so each following element shows as changed — worth remembering when you diff ordered lists.
Related
Working with JSON? See JSONPath Tester to query a document, and JSON Formatter to clean one up first.
Try it
Paste both versions and see exactly what changed — everything runs in your browser, nothing uploaded.