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".

03Limitations

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

  1. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF (accessed 2026-09-01)
  2. RFC 6901: JavaScript Object Notation (JSON) Pointer — IETF (accessed 2026-09-01)