JSON Diff — Compare Two JSON Objects Online

Compare two JSON objects and see exactly what changed. Identify added, removed, and modified paths with color-coded output. Perfect for API response debugging and config file auditing. 100% client-side — your data stays private.

JSON Diff

JSON A (Original)
JSON B (Modified)

What is a JSON diff? A JSON diff compares two documents by structure rather than by text, walking both trees in parallel and reporting the paths where they disagree. Every difference is one of three kinds: a path present only in B (added), a path present only in A (removed), or a path present in both with a different value (changed). Because the comparison is structural, reformatting or reordering keys produces no differences at all.

How to Use the JSON Diff Tool

  1. Paste the baseline into JSON A — The left panel is the "before" document — the committed config, the previously recorded API response, the expected fixture. Use Load Sample in either panel to see the output shape before pasting your own data.
  2. Paste the new version into JSON B — The right panel is the "after". Both inputs must be valid JSON on their own; an unquoted key, a trailing comma or a stray comment stops the comparison with a parse error naming the offending position.
  3. Click Compare — The tool parses both sides and walks them together, producing a flat list of differing paths rather than a line-by-line text diff. Matching paths are not printed at all, so the output length reflects how much actually changed.
  4. Read the paths, not the line numbers — Object keys are joined with dots and array elements carry a bracketed index, so address.city and hobbies[1] point at exactly one value each. A + badge marks additions, removals and ~ changes, with the old and new value shown side by side.
  5. Swap the panels to check directionSwap exchanges A and B, which turns every addition into a removal. It is the quickest way to confirm you are reading a rollback the right way round, or to re-run a comparison after loading the wrong file first.

How the Diff Engine Works

A text diff of two JSON files answers the wrong question. Re-indent a payload, sort its keys, or let a serialiser emit them in a different order and a line-based tool reports dozens of changes even though the data is identical. This tool parses both sides first with JSON.parse and compares the resulting values, so formatting, whitespace and key order carry no meaning at all — only structure and values do.

The comparison is a single recursive walk over both trees at once, and which branch it takes depends on what it finds at the current position:

  • Two objects. It takes the union of the keys on both sides. A key only in A is reported as removed, a key only in B as added, and a key in both is followed one level deeper.
  • Two arrays. It walks positions 0 to the longer array's last index. Positions present in both are compared recursively; the surplus tail of the longer array is reported as added or removed.
  • Anything else. Two scalars, or a type mismatch such as an object on one side and a string on the other, are compared as whole values and reported as a single change if they differ.

The output is therefore a flat list of leaf paths rather than a nested tree. That is deliberate: a list can be scanned, counted and pasted into a ticket, and the summary tag gives you the added, removed and changed totals at a glance. When the two documents match, nothing is printed and the tool says so explicitly instead of showing an empty result.

Path Notation

Each reported path is a directly usable address into the document, built the same way you would write the accessor in JavaScript.

Path shownMeans
emailA top-level key
address.cityThe city key inside the address object — dots join object levels
hobbies[1]The second element of the hobbies array — indices are zero-based
orders[0].items[2].skuDots and indices mix freely to any depth
(root)The two documents differ at the very top, for example a number compared against an object

Where a Structural Diff Has Limits

Arrays are compared strictly by position, because JSON arrays are ordered and the tool has no way to know which element is meant to correspond to which. Insert one item at the front of a hundred-element list and every following index shifts, so the diff reports ninety-nine changes plus one addition rather than the single insertion you performed. That result is correct — position [7] really does hold a different value now — but it is not the summary you wanted. When element identity matters more than order, compare the arrays keyed by their id field instead, or sort both sides consistently before pasting them in.

Two other behaviours follow from parsing rather than from the diff itself. If a document contains the same key twice, JSON.parse keeps only the last occurrence, so a duplicate-key bug is invisible here. And numbers are compared after parsing, so 1, 1.0 and 1e0 are all the same value, while the string "1" is never equal to the number 1.

Diff Types

Additions (Green)

A key or value exists in JSON B but not in JSON A. These represent new fields or elements that were introduced.

Deletions (Red)

A key or value exists in JSON A but not in JSON B. These represent fields or elements that were removed.

Modifications (Yellow)

A key exists in both objects but has a different value. Both the old and new values are shown for comparison.

Examples

Example: Simple Value Change

JSON A (Original)
{
  "name": "Alice",
  "age": 30,
  "city": "Boston"
}
JSON B (Modified)
{
  "name": "Alice",
  "age": 31,
  "city": "New York"
}
Result: 2 modifications — age changed from 30 to 31, city changed from "Boston" to "New York".

Example: Nested Object Diff

JSON A
{
  "user": {
    "name": "Bob",
    "role": "admin"
  },
  "active": true
}
JSON B
{
  "user": {
    "name": "Bob",
    "role": "editor"
  },
  "active": true,
  "theme": "dark"
}
Result: 1 modification (user.role: "admin" → "editor"), 1 addition (theme: "dark").

Frequently Asked Questions

The tool detects three types: added paths (present in B but not A), removed paths (present in A but not B), and changed values (same path, different value in A and B).

Yes. Arrays are compared element-by-element by index. If arrays have different lengths, the tool reports which elements were added or removed. Array elements are referenced by index (e.g., items[0].name).

Yes. Key order carries no meaning in a JSON object, and the comparison takes the union of keys on both sides rather than walking them in sequence. Two objects with the same keys written in a different order produce no differences. The same applies to indentation and line breaks, since both documents are parsed before anything is compared.

No. Parsing and comparison both happen in JavaScript in your tab and no request is made with your content. Be aware that pressing Compare also writes both documents into the page URL so a comparison can be bookmarked or reloaded — clear the panels before sharing that link if the payloads contain customer data, tokens or anything else confidential.

Arrays are matched by index, not by identity. Removing or inserting an element shifts every element after it, so each following position genuinely holds a different value and is reported as changed. There is no move detection. If you care about which records changed rather than which slots changed, sort both arrays by a stable key first, or compare the objects one at a time.

A text diff compares lines of characters and is sensitive to formatting: reindent a file and every line is flagged. A structural diff parses first and compares values, so it reports user.role changed rather than "line 14 differs". Use this tool when both sides are valid JSON, and the Text Diff tool when they are not — including when you specifically need to see a formatting change.

Not directly — both panels must hold exactly one valid JSON value. To compare a newline-delimited file, wrap the records in square brackets and separate them with commas so the whole thing parses as one array. Trailing commas, comments and unquoted keys from JSON5 or JSONC files also have to be removed first, since JSON.parse follows the strict grammar.

Use Cases

API Response Debugging

Compare expected vs actual API responses to quickly identify where data differs.

Config File Auditing

Verify that environment-specific config files have the expected differences between dev, staging, and production.

Version Comparison

See what changed between two versions of a JSON-based data structure or schema.

Data Validation

Verify data transformations by comparing input and output JSON structures.

Snapshot Test Triage

Paste the stored snapshot and the failing output from a test run to see which fields drifted, instead of reading a wall of red terminal output line by line.

Third-Party API Change Detection

Keep a recorded response from a vendor endpoint and compare it against today's to catch a silently added field or a renamed key before it breaks a parser in production.