{ }JSON Compare

JSON diff · unified format

JSON Diff

A unified diff of two JSON documents: unchanged lines, removals and additions, formatted and sorted so only the real changes show up. Runs in your browser.

Unified diff
Original (A)0 lines
Changed (B)0 lines
Diff

Paste two JSON documents and press Show diff. You get a unified diff you can paste into a review or a changelog.

A JSON diff you can actually read

diff is the tool developers trust because its output is boring and predictable: unchanged lines, lines removed, lines added, in the order they appear. This page gives you the same thing for JSON. Two documents in, a unified diff out, with ---, +++ and a hunk header, so the result can be pasted into a pull request comment, a changelog entry or a ticket.

The reason to use a formatted diff instead of eyeballing two files: minified JSON is one line, so a naive text diff of two minified payloads reports the whole file as changed. This page pretty-prints both sides before comparing, which turns a useless one-line diff into the four lines that actually moved.

Reading the output

The first two lines name the sides. --- original.json is the document in the left box, +++ changed.json is the document in the right box. The third line is the hunk header, @@ -1,18 +1,19 @@, which says the comparison covers the original from line 1 for 18 lines, and the changed document from line 1 for 19 lines.

Below that, every line carries a one-character marker and the content:

  • a space means the line is identical on both sides and is shown for context;
  • - means the line exists in the original only;
  • + means the line exists in the changed document only.

A changed value therefore always shows up as a pair: the old line with -, the new line with +, usually one after the other. A moved key can show up as a removal further up and an addition further down, because a line diff follows position.

The left column numbers the output lines themselves, not the source files, so the two of you can refer to "line 37 of the diff" on a call without counting.

Formatting and key order are switches, not opinions

Format both sides first is on by default and is the reason the diff is readable at all. Turn it off when you are diffing files that are already hand-formatted and you want to preserve the exact spacing — for example when the question is whether trailing whitespace or indentation changed.

Ignore key order is also on by default. JSON objects have no meaningful order: {"id":1,"name":"Ada"} and {"name":"Ada","id":1} carry exactly the same data. With the switch on, both sides are canonicalized with sorted keys before the comparison, so a reordered object produces no diff at all. Turn it off when byte order matters, which in practice means signing, checksums, and comparing the output of two serializers that are supposed to match.

When a line diff is the wrong answer

A unified diff answers "what does the text look like now". Sometimes the useful question is different:

  • "Which fields changed, and to what?" A line diff makes you read pairs of lines. The JSON compare tool on the home page walks both documents as data and lists each changed path once, with the old and new value side by side, and builds a JSON Patch from the same walk.
  • "Did the schema change?" Turn on structure-only comparison there: it compares paths and types and ignores the values, which is what you want when every value is expected to differ.
  • "Are these two files the same document at all?" Read why key order makes JSON files look different first; it is the most common reason for a diff that should not exist.
  • "I want this in CI." The guide to comparing two JSON files in code has the jq, Python and Node.js commands, including the exact jq --sort-keys recipe that canonicalizes before diffing.

Limits

  • The comparison runs entirely in your browser, so both documents together are capped at about 4,000 lines here. Above that the page tells you to use the home page tool, which compares data rather than text and handles larger inputs more comfortably.
  • Arrays are compared position by position. Inserting one element near the top of a long array produces a long diff, and that is correct behaviour for a line diff.
  • Numbers are compared as text here. 1 and 1.0 print differently and will show as a changed line, even though they are the same JSON number. The home page tool compares them as numbers and will not report them.

Frequently asked questions

How do I get a JSON diff of two documents?

Paste the original JSON on the left and the changed JSON on the right; the diff appears automatically a moment after you stop typing. Both sides are pretty-printed first, so minified payloads still produce a readable diff.

What format is the output in?

It is a unified diff: two file header lines, one hunk header, then the content lines marked with a space (unchanged), a minus (only in the original) or a plus (only in the changed document). The same format as a git diff, so it pastes into reviews and tickets.

Can I ignore the order of keys?

Yes. Keys are sorted on both sides before comparing, because JSON objects are unordered, so a document that only had its keys reordered produces no diff. Turn the switch off when you need to see that the serialized byte order changed.

How large a file can it handle?

Roughly 4,000 lines for the two documents combined. The diff runs in your browser, so it is deliberately bounded. Above that, use the JSON compare tool on the home page, which compares the parsed data instead of the text.

What is the difference between this and a JSON Patch?

A line diff shows text, a JSON Patch records operations. The home page tool builds the RFC 6902 patch from a structural comparison, listing each added, removed and replaced path as an operation you can replay or store alongside a migration.

Is my data uploaded anywhere?

No. Both documents are parsed and compared by JavaScript in your tab. There is no upload endpoint and nothing is logged, which is the point of doing a diff in the browser at all.