DevToolsmith

JSON Diff

Compare two JSON documents by content. Both are normalized first, so differences in key order, indentation and spacing are ignored and only real changes to the data are shown, with the exact path of each one.

Runs 100% in your browser — nothing is uploaded

Original JSON
Tip: drop a file here161 chars · 161 bytes · 1 line
Changed JSON
Tip: drop a file here228 chars · 228 bytes · 6 lines

Both documents are parsed and pretty-printed with sorted keys first, so key order and formatting never show up as changes.

Why a plain text diff isn’t enough for JSON

The same data can be written in many ways. A serializer that orders keys differently, or a formatter that changes indentation, makes a text diff light up on every line even though nothing changed. This tool parses both documents, sorts object keys at every level and pretty-prints them the same way before comparing. What’s left is the real difference.

Reading the results

  • Line diff: removed lines in red, added in green, with changed words highlighted.
  • Changed paths: one row per difference, using JSONPath-style paths like $.scripts.build or $.items[2].price. Use them directly in the JSONPath tester.
  • Type changed: the value at a path changed type, e.g. from a number to a string. A frequent cause of API bugs.

Compare JSON on the command line

# Normalize with jq (-S sorts keys), then diff
diff <(jq -S . a.json) <(jq -S . b.json)

# Exit code only: 0 if equal
jq -n --slurpfile a a.json --slurpfile b b.json '$a == $b'
Python
import json

with open("a.json") as f, open("b.json") as g:
    print(json.load(f) == json.load(g))  # dict comparison ignores key order

Comparing plain text, config files or code? Use the Diff Checker. To tidy a single document, use the JSON formatter.

Frequently asked questions

How do I compare two JSON files?

Paste the original JSON on the left and the changed JSON on the right. The tool parses both, sorts keys and formats them identically, then shows a line diff and a table of every changed path such as $.dependencies.astro.

Does key order matter when comparing JSON?

Not for this tool. Objects in JSON are unordered, so {"a":1,"b":2} and {"b":2,"a":1} contain the same data and are reported as identical. Array order does matter, because arrays are ordered lists.

How are arrays compared?

Element by element, by index. If an item is inserted at the start of an array, every following index changes, so the path table can show many changes; the line diff above it usually makes the insertion obvious.

Is 1 the same as "1" or 1.0?

1 and "1" are different types (number and string) and are reported as a type change. 1 and 1.0 are the same number in JSON’s data model, so they compare as equal in both the line diff and the changed paths. Numeric notation is normalized without rounding large integers or precise decimals.