What a JSON diff does: it parses both documents and compares structure instead of text. Matching keys are compared recursively, missing keys become additions or removals, and array items are paired by deep equality, so a reordered list reports moves like $.items[0] 2→0 instead of rewriting the whole array as deletes and adds. Key order and whitespace never count as changes, and everything runs in your browser.

Compare Two JSON Documents

Results

0
Added
0
Removed
0
Modified
0
Moved
Paste two documents and press Compare.
Advertisement

Change Types and Path Syntax

OperationMeaningExample Path
addedKey or array item exists only in the changed document$.coupon
removedKey or array item exists only in the original$.items[1]
modifiedSame location, different value (or different type)$.total
movedDeep-equal array item whose index changed$.items[0] 2→0
Root is $, object keys walk as .key, arrays index as [n], and keys with special characters use bracket form: $["weird key!"]

Structural Diff vs Line Diff

ChangeText diff showsJSON diff shows
Reordered object keysEvery affected line changedNothing (order is irrelevant in JSON)
Reformatted / re-indentedWhole file changedNothing
Array reorderedDelete-add pairs across the arrayMoves with from→to indexes
One field changedOne changed line, plus contextOne modified entry with old and new value
Key renamedTwo line changesOne removal + one addition (no way to know intent)

For prose, code, and CSVs, a line diff is still the right tool, and our diff checker handles those. The JSON diff earns its keep the moment structure, not text, is what changed.

How the JSON Diff Works

This tool follows the structural approach popularized by the classic MIT-licensed JSON diff libraries (jsondiffpatch, json-diff): parse both documents, then recurse. Objects compare key by key, and every leaf comparison that fails becomes one modification entry. Nothing is guessed: two objects that merely look similar are never reported as a single "edit."

The algorithm

For objects, keys present in only one side become additions or removals; shared keys recurse. For arrays, items are paired by deep equality, duplicates pair in document order. Paired items whose index changed are reported as moves; unpaired originals are removals and unpaired newcomers are additions. The output is a flat list of operations with full paths from the root, which is exactly the shape you want for review or for driving a patch.

How to use it

Paste your two documents and press Compare. Invalid JSON surfaces the parser error with its position instead of a garbage diff. Toggle ignore-array-order when the sequence of a list shouldn't count, common with sets of tags or IDs. Copy report produces a plain-text summary you can paste into a pull request or ticket.

A worked example

The Load sample button fills both panes with an order record before and after an edit. Comparing them produces seven changes: $.customer.email modified from [email protected] to [email protected], $.total modified from 42 to 50, item A1 moved from index 0 to 1, item C3 moved from index 2 to 0, item B2 removed, item D4 added, and a new $.coupon key set to "SAVE5". A line diff on the same pair shows the entire items array rewritten, which is technically true and completely useless for review.

Worth knowing: 1.0 and 1 compare equal because JSON doesn't distinguish them after parsing, and two arrays with the same items in a different order are genuinely different JSON, which is why move detection exists rather than silent tolerance.

Frequently Asked Questions

How do I compare two JSON files?

Paste the first document into the left box and the second into the right, then hit Compare. The tool parses both, walks the structure, and lists every difference as a path with its old and new value. Invalid JSON is reported with the parser's error position so you can fix it before diffing.

What does a JSON diff do that a text diff doesn't?

A text diff compares characters, so reformatting, reordering keys, or changing indentation shows up as noise across every line. A structural diff parses both documents first: key order is ignored, whitespace never matters, and array items that merely moved position are reported as single moves instead of delete-add pairs spanning the whole array.

How does array-move detection work?

The tool pairs array items by deep equality, matching each item in the original to an identical item in the changed document, with duplicates paired in document order. Paired items whose index changed are reported as moves with both positions. If you'd rather treat reordering as irrelevant, the ignore-array-order option suppresses move reports entirely.

Why does a changed array item show up as removed and added?

Because pairing happens by exact deep equality. An item whose contents changed is no longer identical to anything in the other array, so it can't be paired; the old version is reported removed at its index and the new version added at its index. This is the same trade-off the classic MIT-licensed diff libraries make: unambiguous correctness at the cost of not guessing that two similar objects are 'the same' item.

Is my JSON uploaded anywhere?

No. Parsing, diffing, and rendering all run in your browser with plain JavaScript, and there's no backend call involved. That makes the tool safe for API responses, config files, and anything else you wouldn't paste into a random web form.

What do the paths like $.items[1] mean?

They're the JSON-path style addresses of each change: $ is the document root, .key walks into an object property, and [n] indexes into an array. $.customer.email points at one field; $.items[1] at the second element of the items array. Paths let you turn a diff into a patch list you can apply or review by hand.

Advertisement