Guide
Semantic JSON Comparison
Why a structural JSON comparison ignores formatting and key order, and how to read a path-level change list.
A text diff compares characters, so a reformatted or re-keyed JSON document looks rewritten. A semantic comparison parses both documents and compares the trees instead, so whitespace and, by default, key order cannot produce a difference.
01Text diff versus semantic diff
- A text diff reports indentation, key order, and line endings as changes.
- A semantic diff reports only values that were added, removed, changed, or had their type changed.
- A semantic diff can address each difference by its RFC 6901 path.
02Reading a path-level change list
- Added and removed rows name a path present on only one side.
- Changed rows show the original and changed value at the same path.
- Type-changed rows show both types, for example the number 1 versus the string "1".
Exact numbers
A semantic comparison should keep number literals verbatim, so a 64-bit identifier is compared exactly and never corrupted through a native JSON.parse.
03Limitations
Limitations
A semantic comparison checks structure, not a JSON Schema, and it does not decide which document is correct. It also does not detect array item moves under an index-based strategy.
Frequently asked questions
- Does key order matter in a semantic comparison?
- By default no, because JSON objects are unordered and members are matched by key. Some tools let you turn on an order-sensitive check that reports a differing key sequence at the object's path.
- Is the number 1 the same as the string "1"?
- No. A type-aware comparison reports that path as type-changed rather than equal.
Sources
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF (accessed 2026-09-01)
- RFC 6901: JavaScript Object Notation (JSON) Pointer — IETF (accessed 2026-09-01)
Test this in your browser
The tool runs entirely in your browser; the input you use never leaves it.
About the author
Gampangin builds and maintains free, browser-based developer tools and the documentation that makes them trustworthy. The organization is accountable for every page published on this site.