JSON and data guides
Compare JSON objects and arrays without formatting noise
Compare values deliberately, account for array order, and preserve the difference between absent fields and null.
Choose a semantic comparison
Text comparison reports whitespace and line-break changes. Structural JSON comparison asks whether parsed values and their locations differ.
Format both documents when reviewing them manually, but use JSON Diff to find value changes instead of treating reindentation as data changes.
Left: {"name":"Ada","active":true}
Right: {"active":true,"name":"Ada"}
Object members are reordered; values are unchanged.Array order carries meaning
JSON arrays are ordered. Swapping two entries can matter even if both contain the same objects. Object member order has different interoperability expectations.
For a set-like API response, compare by an agreed stable identifier. Do not sort every array automatically: rankings and event sequences rely on their order.
Inspect value types
The number 1, string "1", null and an absent field are different states. A visually similar output can conceal a contract change.
Use fixtures containing those four cases. Nav Tools preserves large JSON number tokens for comparisons, avoiding a rounded identifier hiding a difference.
{"count":1} ≠ {"count":"1"}
{"count":null} ≠ {}Turn a difference into a check
Decide which fields are volatile, such as request IDs or timestamps, before comparing snapshots. Document exclusions instead of silently deleting fields.
Inspect a changed array element and one added field, then confirm the expected difference. Schema validation is a separate check for allowed fields and types.