JSON Compare

Compare two JSON objects side-by-side and detect added keys, removed keys, changed values, and type differences.

CompareDiffJSONValidate

Differences detected

🟢 Added Keys (2)

phone
status

🔴 Removed Keys (1)

role

🟡 Changed Values (2)

name: "John" → "John Doe"
email: "john@example.com" → "john.doe@example.com"

JSON Compare parses two JSON documents and reports the structural differences between them, key by key. Instead of a line-by-line text diff, it walks both parsed values recursively and lists every key that was added, removed, changed in value, or changed in type, each with its full dot-notation path such as user.address.city.

Results are grouped into four lists: Added Keys (present only in JSON 2), Removed Keys (present only in JSON 1), Changed Values (same path, different value, shown as old -> new) and Type Changes (for example a number that became a string). If both inputs serialize to exactly the same JSON, the tool reports them as identical.

Arrays are compared by index, so tags.0 in one document is matched against tags.0 in the other. Inserting an item at the start of an array therefore shows up as a series of changed values plus one added index, not a single insertion. For a line-oriented view of the same data, pretty-print both sides in the JSON Formatter and use the Diff Checker.

  1. Paste the original JSON into the JSON 1 box and the new or expected JSON into the JSON 2 box.
  2. Click Compare. If either input is invalid JSON, the parser error is shown and nothing is compared.
  3. Read the summary banner: "JSON objects are identical" or "Differences detected".
  4. Review the Added, Removed, Changed Values and Type Changes lists; each entry shows the path to the difference.
  5. Use Swap to reverse the direction (so added becomes removed), or Clear to empty both inputs.

  • Recursive comparison of nested objects and arrays
  • Separate lists for added keys, removed keys, changed values and type changes, each with a count
  • Full dot-notation paths for every difference (array items use their index, e.g. items.2.price)
  • Changed values shown as old -> new, type changes shown as e.g. number -> string
  • Swap button to flip which document is treated as the baseline
  • Parsing and comparison run in your browser; inputs are not uploaded

Comparing two versions of a user record

JSON 1:
{"id": 1, "name": "John", "role": "admin", "active": true}

JSON 2:
{"id": 1, "name": "John Doe", "phone": "+1234567890", "active": "yes"}

Result:
Added Keys (1):     phone
Removed Keys (1):   role
Changed Values (1): name: "John" -> "John Doe"
Type Changes (1):   active: boolean -> string

Each kind of difference is listed separately, so a type change is not mistaken for an ordinary value change.

Nested paths and array indexes

JSON 1:
{"order": {"items": [{"sku": "A1", "qty": 1}], "total": 20}}

JSON 2:
{"order": {"items": [{"sku": "A1", "qty": 2}, {"sku": "B7", "qty": 1}], "total": 35}}

Result:
Added Keys (1):     order.items.1
Changed Values (2): order.items.0.qty: 1 -> 2
                    order.total: 20 -> 35

Differences inside arrays are reported by index; a new array element appears as an added key.

Invalid JSON banner appears instead of results

One of the inputs has a syntax error such as a trailing comma, single quotes, an unquoted key or a comment. The message comes from the browser's JSON parser.

Validate each side separately in the JSON Formatter to find the position of the error, fix it, then compare again.

"Differences detected" but every list is empty

The two documents contain the same keys and values but the keys appear in a different order.

No action needed if key order is irrelevant to you; the data is equivalent.

One inserted array item produces many changed values

Arrays are matched by index, so inserting or removing an element shifts every later element.

Sort both arrays by a stable key (such as id) before comparing, or compare the individual records.

Numbers written differently are reported as equal

Both inputs are parsed as JavaScript numbers, so 1.0 and 1 are equal, and integers larger than 2^53 - 1 can be rounded to the same value.

Represent large IDs and precise decimals as strings if exact textual comparison matters.

Does key order matter?

Key order does not create any entries in the difference lists, because keys are matched by name. However, the identical check compares serialized output, so two objects with the same keys in a different order show "Differences detected" with all four lists empty. That combination means the only difference is key order.

How are arrays compared?

By position. Element 0 is compared with element 0, element 1 with element 1, and so on; extra elements appear as added or removed indexes. The tool does not detect moved or reordered items, so sort arrays consistently before comparing if order is not meaningful in your data.

What counts as a type change?

A type change is reported when the JavaScript typeof of the two values differs, such as number vs string or boolean vs string. Objects, arrays and null all have the type "object", so a change from null to an object, or from an object to an array, appears under Changed Values or as nested key differences rather than as a type change.

Which side is "added" and which is "removed"?

JSON 1 is treated as the original. Keys that exist only in JSON 2 are added; keys that exist only in JSON 1 are removed. Click Swap to reverse the direction.

Can I compare text, YAML or non-JSON files?

No, both inputs must be valid JSON. For plain text or code use Text Compare. YAML can be converted to JSON first with the JSON/YAML converter.