Guide
Comparing two JSON documents
By Logappradeep · ServiceNow developer
When an API response changes between releases, a config file drifts between staging and production, or a snapshot test fails, you need to see exactly what differs between two JSON documents. Scanning by eye works for five lines; it fails for five hundred. A diff tool lines the documents up and highlights only what changed.
How this diff view works
The page uses a side-by-side diff editor. The left pane holds the original document and the right pane the modified one, and both are editable, so you can paste, tweak, and compare repeatedly. Lines that were added, removed, or changed are highlighted, and within a changed line the specific characters that differ are marked as well. In this example only two values differ, so those are the only highlights:
{ "name": "John", "age": 30 }
{ "name": "John Doe", "age": 31 }
Text diff versus semantic diff
This is a text-based comparison. It compares the documents line by line, the way a code review tool does. Two JSON documents can be semantically identical yet produce a noisy text diff when:
- Keys are in a different order.
{"a":1,"b":2}and{"b":2,"a":1}mean the same thing to a parser but appear different as text. - Formatting differs. One file is minified, the other is indented with four spaces.
- Numbers are written differently.
1.0and1are equal values with different text.
To get a clean comparison, run both documents through the JSON Formatter first so they share the same indentation and line layout, and paste the formatted versions here. If key order differs, sorting keys in your own script before comparing removes that noise too.
Array order matters
Arrays are ordered in JSON, so moving an item from position 3 to position 1 is a real change, and the diff will show it as a removal and an addition. If your API returns lists in an unstable order, sort them by a stable key such as id before comparing, or the diff will be full of false alarms.
Practical uses
- Checking what a backend change did to an endpoint's response before merging.
- Comparing feature flag or environment configs across deployments.
- Reviewing why a Jest or Vitest snapshot no longer matches.
- Auditing changes to a
package.json, OpenAPI spec, or Terraform JSON plan.
Both documents stay in your browser while you compare them; nothing is sent to a server.