Drop an original payload on the left and a modified payload on the right to compute a key-order-insensitive structural diff, isolate exact JSONPath changes, and generate an RFC 6902 JSON Patch document.
Line-by-line text diffing falls apart on JSON responses whenever Go maps, Python dicts, or database JSONB columns emit keys in a different order. A two-field mutation can look like a 200-line rewrite in git diff.
Semantic JSON comparison parses both trees first, aligns matching object properties alphabetically, walks nested arrays by index, and reports only genuine data additions, removals, or type/value replacements alongside a ready-to-apply RFC 6902 patch array.
Subtle Traps in Structural API Comparison
01. Type Drift Between String and Number
Changing "port": 5432 to "port": "5432" looks minor visually but breaks strongly typed Go, Rust, and Zod consumers. Semantic diff flags strict primitive type changes immediately.
02. Null Versus Omitted Property Semantics
In PATCH endpoints and GraphQL inputs, an absent key typically means "do not touch" while an explicit null means "clear this column." Deep diff distinguishes removed keys from replaced-with-null values.
03. JSON Pointer Escaping for Slashes and Tildes
When generating RFC 6902 patches for keys containing "/" or "~" (such as Kubernetes annotations), RFC 6901 requires encoding "~" as "~0" and "/" as "~1" so patch applicators target the exact key.
Semantic Change Categories
| Status | RFC 6902 Op | Meaning |
|---|---|---|
| Added (+) | Key or array index exists only in Modified JSON | {"op":"add","path":"/features/v2","value":true} |
| Removed (-) | Key or array index was deleted from Original JSON | {"op":"remove","path":"/legacyFlag"} |
| Changed (~) | Same path holds a different primitive value or JSON type | {"op":"replace","path":"/replicas","value":5} |
| Unchanged | Identical value across both documents regardless of key order | Ignored by default; toggleable |
Worked Engineering Examples
Ignoring Shuffled Object Keys
Left: {"b":2,"a":1} vs Right: {"a":1,"b":2} 0 added, 0 removed, 0 changed (structurally identical)
Reordering object keys does not alter JSON semantics, eliminating noisy false positives during microservice migrations.
Detecting Nested Feature Flag Flip
Left: {"flags":{"canary":false}} vs Right: {"flags":{"canary":true}} ~ $.flags.canary: false -> true (JSON Patch op: replace /flags/canary)
Produces both human-readable JSONPath notation and a machine-applicable patch operation.
Frequently Asked Questions
Does this diff ignore whitespace and object property ordering?
Yes. Both sides are parsed into AST values before comparison, so indentation differences and reordered keys produce zero diff noise.
How are array elements compared?
Arrays are compared index-by-index because JSON array order is semantically meaningful. Extra trailing items appear as added, truncated indices as removed, and altered elements recursively diff their internals.
Can I apply the generated JSON Patch directly in backend tests?
Yes. The patch output conforms to RFC 6902 using add, remove, and replace operations with properly escaped RFC 6901 JSON Pointer paths.
What happens if one side contains invalid JSON?
The engine reports which panel failed (Left or Right) along with the exact line and column of the syntax error without wiping your other pane.