Skip to content
Tools

JSON Diff: Compare Two JSON Documents

Last updated:

A JSON diff compares two documents by structure, not by text, and lists every value that was added, removed or changed along with its path. Because it parses both sides first, reordered keys and different indentation do not show up as false differences.

Runs in your browser: both documents you compare never leaves your device – nothing is uploaded, logged or stored on a server. How we protect your data

100% in-browserNothing is uploaded

Left

Loading editor…

Paste the original JSON

or drop a file anywhere in this box. Everything stays in your browser.

Drop a file to load it

Right

Loading editor…

Paste the changed JSON

or drop a file anywhere in this box. Everything stays in your browser.

Drop a file to load it

Changes

Add JSON on both sides

Differences appear here by path. Key order is ignored.

How to use the JSON Diff

  1. Paste the original JSON on the left and the new version on the right (or drop two files).
  2. Both sides are parsed; if either is invalid you see the line and column of the problem.
  3. Read the change list: each entry shows the path, the kind of change and the old and new value.
  4. Click a change to jump to it in both panes, then copy the summary for a code review or ticket.

Worked example

Two versions of a user record

Left (before)

{"id":7,"name":"Ada","roles":["admin"],"active":true}

Right (after)

{"name":"Ada L.","id":7,"roles":["admin","dev"],"email":"ada@example.com"}

Changes

changed  $.name      "Ada" → "Ada L."
added    $.roles[1]  "dev"
removed  $.active    true
added    $.email     "ada@example.com"

id moved from first to second position but is not reported: object key order has no meaning in JSON. Array positions do matter, so roles[1] is an addition.

Text diff vs. structural JSON diff

Text diff vs. structural JSON diff
SituationLine-based text diffStructural JSON diff
Keys reorderedReports many changed linesNo change
Indent changed from 2 to 4 spacesEvery line differsNo change
1.0 vs 1Different textCompared as numbers
Value changed deep in a nested objectShows the line, not the pathShows the exact path, e.g. $.a.b[2].c
Element inserted at the start of an arrayOne added lineLater elements compared by index, so several may show as changed

How arrays are compared

Arrays are ordered in JSON, so the diff compares them index by index. Inserting one item at the front of a list shifts everything after it, which can make a short edit look like many changes. If your array is really a set of records with IDs, sort both sides by that ID first (the JSON formatter's sort tools help) and then diff.

Strings are compared exactly, including case and whitespace. A trailing space in a value is a real change and will be reported.

When the diff refuses to run

Both inputs must be valid JSON. API logs often contain single quotes, trailing commas or comments; repair them first, then paste the cleaned output back in. Very large inputs are compared in a background worker so the page stays responsive.

JSON Diff FAQ

Does key order matter when comparing JSON?

No. RFC 8259 defines objects as unordered collections of name/value pairs, so {"a":1,"b":2} and {"b":2,"a":1} are equal and the diff reports nothing.

Why does my array show many changes when I only added one item?

Arrays are compared by position. Adding an element at index 0 shifts every later element, so each index now holds a different value. Append to the end, or sort both arrays by a stable key before comparing.

Can I compare two JSON API responses?

Yes. Copy each response body from your browser's network panel or from curl and paste them into the two panes. Volatile fields such as timestamps and request IDs will show up as changes, which is expected.

Is 1 the same as 1.0 in a JSON diff?

Numerically yes, and the diff treats them as equal numbers. If you need byte-level equality, compare the raw text instead.

How do I diff two JSON files from the command line?

A common approach is jq with sorted keys on both files, then a normal diff: diff <(jq -S . a.json) <(jq -S . b.json). This tool gives the same result without installing anything and shows changes by path.

Related tools