How to Compare Two JSON Files
· 2 min read
Two API responses or two versions of a config file often look nearly the same. Reading both by eye is slow, and it is easy to miss a changed value.
JSON Compare reads both documents as data and lists each difference. This guide works through an example, explains how to read the result, and shows where the tool stops.
Why a plain text diff falls short
A plain text diff is a poor fit for JSON. Reordered keys and different indentation show up as changes even when the data is the same, and the differences that matter get buried among the ones that don't. A JSON-aware compare looks at the data instead, whatever the layout.
A worked example
Here is a document before a change:
{ "name": "Ada", "role": "admin", "tags": ["a", "b"], "active": true }
And after:
{ "active": true, "name": "Ada", "role": "editor", "tags": ["a", "b", "c"], "team": "core" }
JSON Compare reports three differences:
| Change | Path | Before | After |
|---|---|---|---|
| Changed | $.role | "admin" | "editor" |
| Added | $.tags[2] | "c" | |
| Added | $.team | "core" |
The role changed, the tags array gained a third item, and a team key appeared. active moved to the front, but that is not reported: key order does not matter in objects, so the data is unchanged.
How paths are written
The Path column uses JSONPath. $ is the root of the document, a name after a dot such as .role is a key, and a number in square brackets such as [2] is an array index. So $.tags[2] means: from the root, take tags, then the item at index 2.
How arrays are compared
Arrays are compared by position: the first item with the first item, the second with the second, and so on.
So if an item is inserted at the start of an array, every later item sits at a new position. Each one shows as changed, and one extra item shows as added at the end. The tool does not detect moved items or treat arrays as sets.
How numbers are compared
Numbers are compared by exact decimal value, not by how they are written. 1, 1.0 and 1e0 are equal, and so are 0.5 and 5e-1. But 1.00000000000000001 and 1 are different, because the tool keeps full precision rather than rounding the way JavaScript does. Big integers keep every digit.
Fields you do not care about
There is no option to ignore fields. Some fields change on every request, such as timestamps or request IDs. Remove them from both documents before you compare; a field left in only one shows as added or removed.
Limits and privacy
The table lists up to 2000 differences. The comparison runs in your browser as you type, and nothing is uploaded.
When to use Text Compare instead
Use Text Compare when you care about formatting, comments or the exact text, or when the files are not valid JSON. If a file has a syntax error, the JSON Formatter points to it.
Try it
Paste your two documents into JSON Compare and read the table of changes.