JSON Diff Comparator
Compare two JSON payloads locally by structure with explicit array matching, ignored paths, path-level changes, patch-style evidence, chart counts, and exportable ledgers.{{ reportText }}
| Path | Status | Original | Revised | Note | Copy |
|---|---|---|---|---|---|
{{ row.Path }} |
{{ row.Status }} | {{ row.Original }} |
{{ row.Revised }} |
{{ row.Note }} |
| Operation | Path | Original | Revised | Copy |
|---|---|---|---|---|
| {{ row.Operation }} | {{ row.Path }} |
{{ row.Original }} |
{{ row.Revised }} |
{{ jsonText }}
Introduction:
Structural JSON comparison looks past line wrapping and indentation to compare the parsed values inside two JSON texts. That is the right shape of review when an API response, fixture, export, or configuration snapshot has the same general layout but a few fields, array items, or value types may have changed.
JSON diffs are useful because one field path can carry more meaning than many lines of braces. A changed status value, a removed feature flag, an added object member, or a string that became a number can matter even when the surrounding payload is mostly identical. Path-level review helps a reader discuss the exact field instead of pointing at a large pasted block.
Structure-aware comparison also prevents common false alarms. Reformatting a payload from one line to many lines should not count as a change. Object member order usually should not matter after parsing. Array order, however, can be meaningful for patches and ordered lists, so array matching rules must be chosen with the review purpose in mind.
A structural diff is still not a schema validator or business-rule test. It can show that $.order.status changed from "pending" to "paid", but it cannot decide whether the new value is allowed by the receiving API.
How to Use This Tool:
Choose the review profile and array policy before trusting the changed-path count.
- Set Comparison profile to API regression, Config drift, Migration audit, or Strict patch review. The profile adjusts the starting choices for array matching, row scope, and type handling.
- Paste the baseline into Original JSON and the candidate into Revised JSON. You can also drop text into either editor or use Browse original and Browse revised for JSON or TXT files under 4 MB.
- Use Format or Format both when a parser error is hard to read. If parsing fails, the alert names the input and usually gives the line and column near the first syntax problem.
- Set Array matching. Use position matching for patch-like ordered arrays, primitive sorting when scalar order is noise, or object-key matching when each object has a stable identifier such as
id,sku, orcode. - Open Advanced when needed. Type policy decides whether numeric strings such as
"42"can match the number42. Ignore paths accepts dot-style paths or JSON Pointer paths, with*at the end for a prefix match. - Choose Ledger rows as Differences only, All traversed paths, or Summary rows. This changes the Path Ledger table and the ledger-row portion of the JSON view; summary counts, chart rows, and patch-style rows still use the full comparison.
- Review Diff Report first, then use Path Ledger, Patch Ops, Change Mix Chart, or JSON for the evidence format you need. If the report says captured rows were capped, use a smaller extract before relying on exported tables.
The practical final check is the summary line plus any review notes in Diff Report. They should match the array and type rules you intended before you copy, download, or share evidence.
Interpreting Results:
Changed paths is the main triage count. It includes added paths, removed paths, changed primitive values, and JSON type changes after the active ignore, array, and type rules. A summary of No differences means no counted differences remain under those rules; it does not prove the two pasted texts are byte-for-byte identical.
- Added means the path exists only in Revised JSON.
- Removed means the path exists only in Original JSON.
- Changed means both paths exist with the same JSON type but different primitive values or changed container evidence.
- Type changed means the same path moved between JSON types, such as string to number or object to array.
- Ignored means the path was skipped by the ignore list and should not be counted as reviewed.
False confidence usually comes from three settings: ignored paths, numeric-string coercion, and object-key array matching. Check Diff Report notes when object-key matching falls back to position matching, and switch Ledger rows to All traversed paths when you need evidence for unchanged or coerced matches.
Use Patch Ops as review evidence, not as a guaranteed ready-to-apply patch. The rows show add, remove, and replace-style operations with paths and values, but array matching by object key can produce reviewer-friendly paths that are not plain array indexes.
Technical Details:
A JSON text represents one serialized value: object, array, string, number, boolean, or null. After parsing, whitespace and pretty-printing no longer affect the value. Object member order is not a reliable semantic signal, while array order remains significant unless the comparison deliberately uses a different array policy.
Object member names should be unique for predictable interchange. Ordinary JSON parsing can lose duplicate-member evidence because one value may overwrite another before the comparison walk begins. If duplicate names are a risk in the input, validate that separately before treating a clean structural diff as complete review evidence.
Transformation Core:
| Stage | Rule | Result to Check |
|---|---|---|
| Parse | Both editors must contain one valid JSON value. Empty input or syntax failure stops the comparison. | Input issue alert and parser location when available |
| Walk values | Objects are traversed by sorted member names, arrays by the selected array policy, and primitives by value and type. | Total rows, Changed paths, and status counts |
| Apply ignore rules | Exact dot paths or JSON Pointer paths are skipped, and a trailing * skips every path with that prefix. |
Ignored rows and ignored-path count |
| Build evidence | Rows become a report, path ledger, patch-style operations, chart counts, and a structured JSON result. | Diff Report, Path Ledger, Patch Ops, and JSON |
Formula Core:
The headline changed-path count is the sum of path statuses that represent material differences after the active comparison rules.
Ignored rows and Unchanged rows are not part of Changed paths. In Differences only mode, unchanged matches may not appear in the ledger at all, so the absence of a row can be the expected result for an equal path.
| Array Policy | Comparison Rule | Best Use |
|---|---|---|
| Compare arrays by position | Index 0 compares with index 0, index 1 with index 1, and so on. | Ordered arrays, strict patches, lists where position changes meaning. |
| Sort primitive arrays | Primitive values are counted by stable value, so order-only changes in scalar arrays can disappear. | Tags, flags, small scalar sets, and unordered lists of strings or numbers. |
| Match object arrays by key | Objects are matched by the selected member value when every item on both inputs has that member. | API item arrays, product rows, fixtures, or exports with stable identifiers. |
| Fallback to position | If a requested object key is missing from any item, comparison returns to index matching and records a review note. | Use the note to choose a better key or switch to position matching deliberately. |
| Notation | Meaning | Caution |
|---|---|---|
| Dot path | Readable field paths such as $.order.status or $.items[0].sku. |
Best for review notes and human discussion. |
| JSON Pointer | Slash-separated paths such as /order/status, with ~ and / escaped inside reference tokens. |
Best for standards-based path exchange when paths use ordinary object names and array indexes. |
| Patch-style operation | add, remove, and replace rows summarize how a path differs. | Move, copy, and test operations are not inferred, and object-key array paths may need conversion before applying elsewhere. |
Large comparisons keep full status counts while table artifacts capture a bounded row set. When the report notes omitted captured rows, the safest review path is to narrow the JSON to the object or array under investigation and rerun the comparison.
Privacy Notes:
After the page loads, parsing, local file reading, structural comparison, charts, copying, and downloads run in the browser tab. Pasted JSON and supported file contents are not uploaded by the comparison workflow.
- Use caution with secrets, tokens, customer records, and unreleased API payloads. Browser history, screenshots, clipboard contents, and shared links can still expose sensitive data.
- The page can preserve current inputs in the browser address bar for sharing and restoration. Remove sensitive values before copying a link.
- Only JSON and TXT files under 4 MB are accepted through the file buttons or drag-and-drop path.
Worked Examples:
Order API regression. The built-in sample compares an order that moves from "pending" to "paid", changes the customer tier, updates item sku=A1, adds item sku=C3, and ignores $.order.meta.request_id. With object-key matching on sku, the summary reports 7 changed paths, 8 path rows, and 1 ignored path. Path Ledger shows the exact changed fields, while Patch Ops lists add and replace-style evidence.
Array reorder during fixture cleanup. For [{"id":1,"v":"a"},{"id":2,"v":"b"}] compared with [{"id":2,"v":"b"},{"id":1,"v":"a"}], position matching reports four changed primitive paths because each index now holds a different object. Object-key matching with id reports No differences because the same two objects are still present.
String-to-number migration. Comparing {"count":"42"} with {"count":42} under Strict JSON types gives a Type changed row at $.count. Under Coerce numeric strings, the same pair can disappear from Differences only because the numeric value matches after coercion. Use All traversed paths if you need an unchanged row as audit evidence.
Bad input during review. If Original JSON contains {"id":42,}, the comparison stops with an Input issue parse message instead of producing misleading rows. Fix the trailing comma, use Format to confirm the value parses, then rerun the comparison before reading Diff Report.
FAQ:
Why does formatting not count as a difference?
The comparison parses both inputs as JSON values before walking paths. Whitespace, indentation, and line wrapping are not part of the parsed value, so they do not create changed rows.
Why did an array reorder create many changed paths?
Position matching treats each index as meaningful. If order is not meaningful and each object has a stable identifier, choose Match object arrays by key and enter that identifier in Array object key.
Are Patch Ops a valid JSON Patch file?
They are patch-style review rows, not a complete JSON Patch document. They show add, remove, and replace evidence, but do not infer move, copy, or test operations.
Why do I see no differences when values look different?
Check Ignore paths, Type policy, and Array matching. Ignored paths are skipped, numeric-string coercion can treat "42" and 42 as equal, and object-key matching can ignore order-only array changes.
Does loaded JSON leave the browser?
The comparison work runs in the browser after the page loads. Do not share the page URL, screenshots, exports, or clipboard contents until sensitive values have been removed.
Glossary:
- JSON value
- One parsed JSON object, array, string, number, boolean, or null.
- Structural diff
- A comparison of parsed JSON paths and values rather than raw text lines.
- Dot path
- A readable path form such as
$.order.statusused in ledger rows and ignore rules. - JSON Pointer
- A standards-based slash path such as
/order/statusfor identifying a location inside a JSON value. - Patch operation
- An add, remove, or replace-style row describing how a compared path differs.
- Numeric coercion
- A comparison option that can treat numeric strings and matching JSON numbers as equal.
References:
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format, IETF/RFC Editor, December 2017.
- RFC 6901: JavaScript Object Notation (JSON) Pointer, IETF/RFC Editor, April 2013.
- RFC 6902: JavaScript Object Notation (JSON) Patch, IETF/RFC Editor, April 2013.