JSON Tools

JSON Diff: How to Compare Two JSON Objects Online

Compare two JSON documents side-by-side and highlight every added, removed, and changed value. Ideal for API versioning and config audits.

Published January 15, 2025Updated June 1, 20255 min read

Try the free online tool

Runs entirely in your browser — no signup, no uploads.

Open Tool

When an API changes its response shape, when a configuration file gets updated by another team member, or when a deployment changes environment variables, you need to know exactly what changed — not just that something changed. A JSON diff tool compares two JSON documents and produces a structured, coloured report of every insertion, deletion, and modification.

Text-based diff tools (like `git diff`) treat JSON as plain text, so they flag whitespace changes as differences and miss the semantic relationship between keys. A JSON-aware diff tool understands the structure: it compares keys by name regardless of their order, and reports changes in terms of the actual data model.

This tool takes two JSON inputs, parses them both, and produces a side-by-side visual diff with colour-coded highlights — green for additions, red for removals, and yellow for modifications — so you can audit changes in seconds.

What Is a JSON Diff?

A JSON diff is a structured comparison of two JSON documents that identifies every key or array element that was added, removed, or whose value changed between the two versions. Unlike a line-by-line text diff, a JSON diff is key-aware: it knows that `{"b": 2, "a": 1}` and `{"a": 1, "b": 2}` are semantically identical even though their text representations differ.

JSON diff tools operate recursively. They compare the top-level object or array, then descend into nested objects and arrays to find differences at any depth. The result is a hierarchical change report that mirrors the shape of the original JSON.

Some diff tools also compute a JSON Patch (RFC 6902) — a list of operations (`add`, `remove`, `replace`, `move`, `copy`, `test`) that transforms the first document into the second. JSON Patch is machine-readable and can be applied programmatically.

  • Added keys — keys present in the second document but not the first
  • Removed keys — keys present in the first document but not the second
  • Modified values — keys present in both documents but with different values
  • Type changes — a value that changed type (e.g., string to number)
  • Array changes — elements added, removed, or reordered within arrays

How to Use This Tool

Paste your two JSON documents into the left and right panels, and the diff appears automatically.

  1. 1

    Paste the original JSON

    Put the older or baseline JSON in the left panel — this is the "before" version.

  2. 2

    Paste the modified JSON

    Put the newer or changed JSON in the right panel — this is the "after" version.

  3. 3

    View the diff

    The tool highlights added lines in green, removed lines in red, and changed values in yellow. Unchanged sections are shown in muted text.

  4. 4

    Navigate changes

    Use the change navigator to jump between differences without scrolling manually through large documents.

  5. 5

    Copy or export

    Copy the diff report, or export it as a JSON Patch document for programmatic use.

Common Use Cases

JSON diff is invaluable whenever you need accountability and clarity around data changes.

  • API versioning — compare v1 and v2 API responses to understand breaking changes before updating client code.
  • Feature flag audits — diff configuration snapshots before and after a flag change to confirm only intended settings changed.
  • Database migration checks — compare a document before and after a migration script to validate the transformation.
  • PR reviews — paste before/after JSON snapshots in a pull request comment so reviewers can see the data impact of a code change.
  • Environment parity — compare production and staging config JSON to find configuration drift between environments.

Tips and Best Practices

A JSON diff is most useful when both inputs are formatted consistently and you understand the limits of structural comparison.

  • Format before diffing — ensure both documents use the same indentation; a formatting difference is not a data difference.
  • Ignore key order — use a tool that is key-order-agnostic so that `{"a":1,"b":2}` and `{"b":2,"a":1}` are treated as equal.
  • Array order matters — unlike object keys, JSON array order is significant. Element position changes will appear as differences even if the values are the same.
  • Diff at the right level — if you only care about a sub-section of a large document, extract that subtree and diff it separately for a cleaner result.
  • Use JSON Patch for automation — if you need to apply the same change repeatedly, generate a JSON Patch document and apply it with a library rather than manually editing JSON.

Frequently Asked Questions

Does key order matter when diffing JSON objects?

For data purposes, no — JSON objects are unordered collections. A good JSON diff tool ignores key order and compares by key name. If you use a plain text diff, key order changes will show up as false positives.

Does array element order matter when diffing JSON arrays?

Yes. JSON arrays are ordered sequences, so a reordering of elements is a real structural change. Most JSON diff tools will flag element position changes as differences. If order does not matter semantically in your use case, you may need to sort the arrays before diffing.

What is JSON Patch and how is it related to JSON diff?

JSON Patch (RFC 6902) is a standard format for describing changes to a JSON document as a list of operations. A JSON diff tool can generate a JSON Patch document describing the transformation from document A to document B. You can then apply that patch programmatically using libraries in any major language.

Can I diff two large JSON files?

Browser-based diff tools handle files up to a few megabytes well. For very large files (tens of megabytes), use a command-line tool: `jq` with a custom filter, or the `jsondiff` Python library, which stream-parse files rather than loading both into memory simultaneously.

How do I compare JSON in a unit test?

Most testing frameworks support deep equality checks. In JavaScript/Jest, use `expect(actual).toEqual(expected)`. In Python/pytest, use `assert actual == expected` with dictionaries. These perform key-order-agnostic structural comparison equivalent to a semantic JSON diff.

Why does the diff show changes when the data looks the same?

Check for type differences — `1` (number) and `"1"` (string) look similar but are different JSON types. Also check for extra whitespace inside string values, Unicode normalization differences, or floating-point precision issues (`1.0` vs `1`).

jsonjson diffcompare jsonjson comparisonjson changes

Ready to use this tool?

Free, instant, no account required. Runs entirely in your browser.

Open Tool

More JSON Tools Guides