ToolForge
Advertisement

JSON Diff Comparator

Compare two JSON files and find differences

Written by toolforge.websiteLast reviewed How we build and check these tools

JSON Diff Comparator tool

JSON Diff Comparator: key facts

What it does
Compare two JSON files and find differences
Category
Developer Tools
Cost
Free, with no account, sign-up, or install.
Your data
Runs entirely in your browser — the files and text you enter are never uploaded to a server.
Last reviewed
. Report an incorrect result.
Advertisement

What this tool is for

When two versions of a JSON document should match but something has drifted, scanning them line by line is slow and error-prone. JSON Diff parses both sides and compares them structurally, then reports exactly which fields were added, removed, or changed — by their full path inside the object.

That structural approach is what makes it useful where a plain text diff falls short: reformatting, reordered keys, or different indentation do not create false differences, because the tool compares parsed values rather than characters. API developers reach for it to spot what changed between a working response and a broken one; config owners use it to see which setting differs between staging and production.

Arrays are compared by position and objects by key, so a change at users[2].email is reported precisely there rather than as a vague "something in this block changed".

How to use the JSON Diff Comparator

  1. Paste your first JSON document into the "JSON 1 (Original)" box.
  2. Paste the version you want to compare into "JSON 2 (Modified)".
  3. The comparison runs automatically as you edit — no button to press.
  4. Read the results: each entry shows its path and whether it was added, removed, or modified, with the old and new values for changes.
  5. Use Copy to export the diff as a readable +/-/~ list for a pull request or bug report.

Comparing structure, not text

Both documents are parsed before anything is compared, which is what makes the result meaningful. A textual diff of two JSON files reports every reformatting and reordering as a change; comparing the parsed values ignores whitespace, indentation, and key order entirely, and reports only differences that would actually affect a consumer.

The comparison walks both structures together and records three kinds of finding: a key present in one document and not the other, and a key present in both whose value differs. Each is reported with the path at which it occurs, so a change buried several levels deep is locatable rather than merely flagged.

That path-based output is the reason this beats a text diff for API work. Confirming that a response has changed in exactly one field, and identifying which, is the common task when a deployment alters behaviour.

  • Reformatting a document from minified to indented produces no differences at all.
  • Reordering keys likewise reports nothing, since object key order carries no meaning.
  • A changed value is reported with its path and both the old and new values.

What the JSON Diff Comparator gets right

  • It compares parsed structure, not text, so reformatting or different indentation never shows up as a false change — only real value differences do.
  • Every difference is reported with its full path (such as items[0].price), so you can jump straight to what changed instead of hunting through nested blocks.
  • It distinguishes added, removed, and modified explicitly, including the before and after values for each change.
  • Both documents are parsed and compared entirely in your browser, so unreleased API payloads and config never leave your machine.

Arrays are where comparison gets hard

Objects compare cleanly because keys identify their values. Arrays do not, because position is the only identity available. Insert an element at the front of a list and a positional comparison reports every subsequent element as changed, even though nothing but the offset moved — the same problem a line-based text diff has, and the reason diffing algorithms for sequences are considerably more involved than for maps.

Where array elements carry a stable identifier, comparing by that identifier rather than by index gives far more useful output, but it requires knowing which field is the key. No general-purpose tool can infer that reliably.

Two smaller subtleties. Numeric values that differ only in representation — 1 against 1.0, or a value affected by floating-point imprecision — may or may not be reported depending on how equality is tested. And a missing key and a key present with a null value are genuinely different states that are easy to conflate; treating them as equivalent hides a real class of API change.

Frequently Asked Questions

How is this different from a normal text diff?

A text diff compares characters, so reordering keys or changing indentation registers as differences even when the data is identical. JSON Diff parses both documents first and compares the actual values, so it only flags genuine structural and value changes.

Does the order of keys matter?

For objects, no — keys are matched by name, so {"a":1,"b":2} and {"b":2,"a":1} are treated as equal. For arrays, order does matter, because elements are compared by their index position.

Why am I getting an "invalid JSON" error?

One of the two inputs is not valid JSON — often a trailing comma, a missing quote, or an unclosed bracket. Both sides must parse successfully before they can be compared; format each one in a JSON formatter first if you are unsure.

Related Tools

Advertisement
Buy Me a Coffee