deep · sorted · LCS-based

Compare two JSON documents side by side

Sorted keys mean diffs show real changes, not order noise. Added / removed / unchanged lines highlight automatically.

JSON Diff Workspace
Left size
74 B
6 lines
Right size
114 B
7 lines
Changes
8
+5 / −3
Status
Changed
key-sorted
Keys sorted before comparison · unified diff formatChanged+5 / −3
left · original
right · changed
unified diff
{
"active": true,
+ "city": "London",
+ "name": "Ada Lovelace",
- "name": "Ada",
"roles": [
+ "admin",
+ "founder"
- "admin"
],
+ "score": 95
- "score": 92
}
Quick Start

How to diff two JSON documents

Compare two JSON documents structurally, not lexically. Keys are sorted first, then a unified diff identifies added / removed / unchanged lines.

  1. 01

    Paste both sides

    Drop the original on the left, the changed version on the right. Both must be valid JSON.

    Inputs parse through the native JSON.parse reviver chain — strict RFC 8259. Any syntax error returns line and column for the exact offending byte.

    bothRFC 8259JSON.parsestrictlive
    input · raw2 sides · RFC 8259
    L: {"name":"Ada"}
    R: {"name":"Ada","city":"London"}
    loaded · parsed RFC 8259RFC 8259 · ready
  2. 02

    Keys sorted

    Before diffing, both sides are pretty-printed with sorted keys. So reordering doesn't show as a change.

    Indent options run through JSON.stringify(value, null, n); the second argument lets you sort, transform, or omit keys via a replacer if you ever wire one in.

    sortedcanonicalindentJSON.stringifylive
    canonical · optionsstable · live
    name first, then city
    options applied · livelive
  3. 03

    Inspect added / removed

    Green + lines = added in right. Red - lines = removed from left. Unchanged lines stay grey.

    Large documents stream through a useMemo with stable hashing so options re-apply instantly — no full re-parse if only formatting changes.

    greenredmemoisedinstantdiff-friendly
    diff · renderedcolor · ready
    + "city": "London"
    rendered · livediff-friendly
  4. 04

    Copy unified diff

    One click copies the patch-style output for pasting into a PR, issue, or chat.

    Download is a Blob with application/json; copy uses the Async Clipboard API. Both round-trip identically to what the page rendered.

    unifiedPR-readyclipboardblob.json
    export · copiedready · done
    ✓ Copied diff
    shipped · ready to shipsuccess
Pro tips

Production-grade JSON, the right way

Stick to RFC 8259

Strict JSON has no NaN, Infinity, comments, or trailing commas. If you need those, look at JSON5 or JSON Repair.

Preserve key order for diffs

JavaScript preserves insertion order, but two parsers shouldn’t be assumed equal. Use Sort JSON Keys before diffing or hashing.

Big integers lose precision

JS numbers lose precision past 2^53−1. Transport large IDs as strings or use BigInt.

Escape inside HTML

When inlining JSON inside <script>, escape </ to <\/ so HTML parsing doesn’t close your tag early.

Validate at boundaries

Trust the wire as little as possible. Run incoming JSON through a schema (Zod / Pydantic) before it touches business logic.

Minify in production

Minify removes whitespace; gzip removes redundancy. Together they typically shrink JSON payloads 70–85% over the wire.

Use Cases

When to diff JSON

Wherever two JSON documents should match — or shouldn't.

API contract drift

Compare two responses from different versions to spot breaking changes. Output round-trips losslessly through JSON.parse + JSON.stringify, so the file you save is byte-identical to what you see. Streaming parsers, jq pipelines, and Postgres jsonb columns all accept the result without complaint.

spot drift early

Config diff

Compare two Helm/k8s YAML outputs (after JSON conversion) for environment delta. Pairs perfectly with sort-keys + diff for review-friendly fixtures in CI. Whitespace-only churn disappears and reviewers see real changes, which keeps PR comments focused on logic rather than indentation.

cleaner PR diffs

Test snapshot review

When a snapshot test fails, diff old vs new JSON to see what changed. Handles emoji and non-ASCII via UTF-8 throughout — your data survives copy-paste between editors, terminals, and IDEs. Combining marks and ZWJ sequences come out the other side intact.

RFC 8259 valid

Fixture review

Confirm you only changed what you intended in a fixture file. Re-parses on every keystroke so syntax errors are caught at the exact character. Strict RFC 8259 — no trailing commas, no comments, no unquoted keys — keeps downstream parsers happy.

round-trip safe

Cache invalidation

Compare cache contents with source to confirm staleness. Streams large documents without a server round-trip — privacy stays in the tab. Heavy parsing runs through useMemo so even 5 MB payloads keep the editor responsive.

schema-friendly

Webhook deduping

Confirm two webhook payloads are functionally identical. Output is byte-stable: same input plus same options always produces identical bytes, ideal for content-addressed caches and snapshot tests. Downloads ship with the application/json MIME so editors apply syntax highlighting.

production-ready
FAQ

Frequently asked questions

No — both sides are sorted before diffing, so reordering doesn't show up as a change.
Yes — arrays compare positionally. A reordered array shows as added/removed lines.
Tens of MB before things slow down. The LCS algorithm is O(n²) so very large inputs are sluggish.
No. All diffing runs locally.
Yes — copy as unified diff (the standard +/- prefixed format).
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!