W3docs

Tools

JSON Diff

Compare two JSON documents by structure. Key order and formatting are ignored, arrays can be matched by index or by a key such as id, and every added, removed and changed path is listed and highlighted side by side.

Your JSON stays on this device: it is parsed and compared in your browser and never uploaded.

0 chars
0 chars
Match arrays
  • Added–
  • Removed–
  • Changed–

About the JSON diff tool

This tool compares two JSON documents by structure, not by text. Both inputs are parsed, so key order, indentation and line breaks never show up as differences. What is left is a list of real changes: paths that were added (only in the modified JSON), removed (only in the original) or changed (present in both with a different value or type).

Each change is reported by its path, such as $.address.city or $.items[2], and highlighted in a side-by-side view of both documents. An added or removed object counts as one change at its root, and a value that changes type (for example 1 to "1", or null to 0) is a change, not an edit inside it.

Arrays are compared position by position by default. If your arrays hold records with an identifier, switch to matching by key (for example id): elements are then paired by that value, so a reordered list is not reported as a change, and the path shows which record changed, like $.users[id=3].role.

The parser keeps numbers exactly as written. JSON.parse in JavaScript rounds integers above 2^53, so 9007199254740993 and 9007199254740992 would look equal; here they are compared digit by digit. Invalid JSON is reported with the input (A or B), line and column of the first error.

Everything runs in your browser. Large documents (several megabytes, hundreds of thousands of lines) are compared in a background worker, and nothing you paste or open is uploaded.

Worked example

Compare an original document (A) with a modified one (B). Keys were reordered and one value changed type.

Input A (original)json
{
  "name": "Ann",
  "age": 30,
  "address": { "city": "Paris", "zip": "75001" },
  "active": true
}
Input B (modified)json
{
  "address": { "zip": "75001", "city": "Lyon", "country": "FR" },
  "age": "31",
  "name": "Ann"
}
Resulttext
Added (1)
+ $.address.country: "FR"

Removed (1)
- $.active: true

Changed (2)
~ $.age: 30 → "31"
~ $.address.city: "Paris" → "Lyon"

The new key order of B is ignored. age is a change because its type went from number to string.

Frequently asked questions

Does the order of keys matter?

No. JSON objects are unordered, so {"a":1,"b":2} and {"b":2,"a":1} are equal. Formatting and whitespace between tokens are ignored too; whitespace inside string values is kept and compared.

How are arrays compared?

By index by default: element 0 against element 0, and so on, with extra trailing elements reported as added or removed. Choose "By key" and enter a field such as id to pair objects by that field instead, so reordering is not a change.

What happens when an array cannot be matched by key?

If its elements are not all objects with a unique scalar value for the key, that array is compared by index instead and a note names the array, so the result is never silently guessed.

Are large numbers compared correctly?

Yes. Numbers are kept as their exact digits, so integers beyond 2^53 (such as 64-bit IDs) are compared and shown without rounding. Different spellings of the same value, like 1.0 and 1, are treated as equal.

Is null the same as a missing key?

No. null is a value: a key whose value goes from null to 0 is changed, while a key that exists with null on one side and is missing on the other is added or removed.

Is my JSON uploaded anywhere?

No. Parsing and comparing happen in your browser, in a background worker for large files. The page sends nothing you paste, drop or open to a server.