Compare two JSON documents side by side
Sorted keys mean diffs show real changes, not order noise. Added / removed / unchanged lines highlight automatically.
{"active": true,+ "city": "London",+ "name": "Ada Lovelace",- "name": "Ada","roles": [+ "admin",+ "founder"- "admin"],+ "score": 95- "score": 92}
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.
- 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.parsereviver chain — strict RFC 8259. Any syntax error returns line and column for the exact offending byte.bothRFC 8259JSON.parsestrictliveinput · raw2 sides · RFC 8259L: {"name":"Ada"} R: {"name":"Ada","city":"London"}loaded · parsed RFC 8259RFC 8259 · ready - 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.stringifylivecanonical · optionsstable · livename first, then city
options applied · livelive - 03
Inspect added / removed
Green
+lines = added in right. Red-lines = removed from left. Unchanged lines stay grey.Large documents stream through a
useMemowith stable hashing so options re-apply instantly — no full re-parse if only formatting changes.greenredmemoisedinstantdiff-friendlydiff · renderedcolor · ready+ "city": "London"
rendered · livediff-friendly - 04
Copy unified diff
One click copies the patch-style output for pasting into a PR, issue, or chat.
Download is a
Blobwithapplication/json; copy uses the Async Clipboard API. Both round-trip identically to what the page rendered.unifiedPR-readyclipboardblob.jsonexport · copiedready · done✓ Copied diff
shipped · ready to shipsuccess
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.
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 earlyConfig 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 diffsTest 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 validFixture 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 safeCache 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-friendlyWebhook 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-readyFrequently asked questions
Something missing?
Tell us what you need. We ship the top requests every two weeks.