How to compare two JSON files
- Paste the original JSON (A) on the left and the changed JSON (B) on the right, or press Upload above either box. Sample loads the example below.
- The comparison runs as you type. The summary shows how many values were added, removed and changed.
- Each difference lists its path, like
$.address.zip, with the old value struck through and the new value next to it. Click a path to copy it. - Tick Ignore array order if the order of list items doesn't matter. Swap sides reverses the comparison, Format both tidies the inputs, and Copy report copies every difference as text.
If either side is not valid JSON, the tool tells you which one and the line and column of the error. The JSON formatter and validator explains how to fix it.
JSON diff example
Version A of a user record:
{
"id": 7,
"name": "Ada",
"roles": ["admin", "dev"],
"address": { "city": "London" }
}Version B: the keys are in a different order, and some values have changed:
{
"address": { "zip": "N1", "city": "London" },
"active": true,
"id": 7,
"name": "Ada Lovelace",
"roles": ["admin", "dev", "ops"]
}A line-by-line diff checker would flag almost every line. The JSON compare result is 4 differences, 3 added and 1 changed:
| Change | Path | A | B |
|---|---|---|---|
| Changed | $.name | "Ada" | "Ada Lovelace" |
| Added | $.roles[2] | – | "ops" |
| Added | $.address.zip | – | "N1" |
| Added | $.active | – | true |
id and address.city are not listed because their values are the same, even though they moved.
Compare JSON ignoring array order
By default, arrays are compared item by item: item 0 with item 0, item 1 with item 1. That is right for ordered lists, but noisy when the order doesn't matter, such as a list of line items from two systems:
A: [{"sku":"A1","qty":2}, {"sku":"B2","qty":1}, {"sku":"C3","qty":5}]
B: [{"sku":"C3","qty":5}, {"sku":"A1","qty":2}, {"sku":"B2","qty":4}]Compared by position, all three items look different: 6 changes, every sku and qty. With Ignore array order ticked, identical items are matched first wherever they are, and the result is the one real change:
| Change | Path | A | B |
|---|---|---|---|
| Changed | $[1].qty | 1 | 4 |
Paths use the item's position in A (for added items, its position in B).
What counts as a difference
- Ignored: key order, whitespace, indentation, line breaks, and how a number is written (
1,1.0and1e0are equal). - Added: a key or array item that exists only in B.
- Removed: a key or array item that exists only in A. A key set to
nullis not the same as a missing key. - Changed: a different value, or a different type at the same path, such as a string
"2"becoming the number2, or an array becoming an object.
For example, comparing {"price": 1, "qty": "2", "tags": null, "items": []} with {"price": 1.0, "qty": 2, "items": {}} gives:
| Change | Path | A | B |
|---|---|---|---|
| Changed | $.qty | "2" | 2 |
| Removed | $.tags | null | – |
| Changed | $.items | [] | {} |
price is not listed: 1 and 1.0 are the same number.
JSON compare vs a text diff checker
A text diff checker compares lines. Run a formatter over a file, or let a serializer write keys in a different order, and a text diff shows the whole file as changed. A semantic JSON diff parses both sides first and compares the data, so it only reports changes that a program reading the JSON would notice, and it names each one by path instead of by line number. That makes it the better tool for checking API responses before and after a deploy, reviewing config changes, and debugging snapshot tests.
More JSON tools
- JSON viewer: explore one document as a collapsible tree and copy the path to any value.
- JSON formatter: pretty print, minify and validate JSON.
- JSON to CSV: open an array of objects in a spreadsheet, where you can compare rows side by side.
- Unix timestamp converter: turn epoch times from API responses into readable dates.
Frequently asked questions
How do I compare two JSON files?
Paste the original JSON on the left and the new version on the right, or press Upload above each box to open a file. The differences appear as you type: each one is labelled added, removed or changed, with the path to the value and the old and new values. Press Copy report to paste the list into a ticket or pull request.
Does key order matter when comparing JSON?
No. In JSON an object is an unordered set of keys, so {"a":1,"b":2} and {"b":2,"a":1} are the same data, and this tool reports them as equal. Whitespace, indentation and line breaks are ignored too. Array order does matter by default, because [1,2] and [2,1] are different lists; tick Ignore array order if yours are really sets.
Can I compare JSON and ignore array order?
Yes. Tick Ignore array order. Items that are identical on both sides are paired up wherever they are in the array, the remaining items are compared with each other in order, and anything left over is reported as added or removed. It applies to nested arrays too. Duplicates count: ["a","a"] and ["a"] are still different.
Is my data uploaded?
No. Both documents are parsed and compared by JavaScript in your browser. Nothing you paste is sent to our servers, logged or saved, which matters when you compare API responses or config files that contain customer data or secrets.
What is the difference between a JSON diff and a text diff checker?
A text diff compares lines, so reformatting a file or reordering its keys shows up as dozens of changes even when the data is identical. A JSON diff parses both documents first and compares the data itself, so it reports only real changes, and it tells you where they are as a path such as $.address.zip rather than a line number.
Why are 1 and 1.0 reported as the same, but 2 and "2" as different?
1 and 1.0 are the same JSON number written two ways, like 1e0. "2" is a string and 2 is a number, which are different types, so that is a change. Likewise a key set to null is different from a key that is missing: the first is a value, the second is removed.
How do I compare JSON in Python?
Load both files with json.load and compare the results with ==. Python dicts ignore key order, so equal data gives True, but lists are compared in order and you only get True or False, not the differences. Libraries such as DeepDiff list the differences. For a quick check, pasting both files here is faster.
Can it compare large JSON files?
Yes. Documents of a few megabytes each compare in about a second, and the first 1,000 differences are listed on the page (Copy report includes them all). Very large numbers, above 9,007,199,254,740,991, are rounded by JavaScript when parsed, so two IDs that differ only in their last digits may look equal.