JSON Tools

JSON Compare

Compare two JSON documents and surface key, type, and value differences.

  • $.stack: array length differs (3 vs 4)
  • $.stack[3]: type mismatch (undefined vs string)

Understand the format

How JSON Compare works

A structural comparison walks both documents key by key, so it reports meaningful differences instead of the line noise a text diff produces.

Structural diff versus text diff

A text diff compares characters and lines, so reindenting a file or emitting keys in a different order produces a wall of changes that mean nothing. A structural diff parses both sides first and then walks the resulting values, reporting only differences that a consumer of the data would actually observe: a key present on one side, a type that changed, an array whose length differs, or a primitive value that is no longer equal.

This comparison reports each difference with a path such as $.items[0].qty, which reads the same way as the accessor you would write in code. That makes the output easy to translate into a fix or a test assertion.

Which differences deserve attention

Not every difference is a defect. Timestamps, request identifiers, and pagination cursors are expected to change between two captures. Type changes almost always matter: a number that became a string, an object replaced by null, or an array that collapsed into a single value will break strict consumers even when the visible value looks the same.

Key order is never a difference in JSON. If two systems disagree about ordering, that is a serialisation detail, not a contract change, and it is precisely the noise a structural comparison removes.

Step by step

How to use JSON Compare

  1. Paste the known-good document into the left panel, usually the response captured before a change.
  2. Paste the current or failing document into the right panel.
  3. If either side reports a parse error, fix that first; a comparison needs two parseable documents.
  4. Work through the difference list from the top, classifying each entry as expected, cosmetic, or a real contract change.

Both documents are parsed and compared locally in the browser, so two production captures can be diffed without sending either one to a server.

Worked examples

JSON Compare examples explained

A type change hidden behind a similar-looking value

Input

Left: {"total": 25}   Right: {"total": "25"}

Result

$.total: type mismatch (number vs string)

The rendered value is identical in a UI, but arithmetic and strict schema checks break downstream.

A field that disappeared after a deploy

Input

Left: {"id": 3, "email": "a@example.com"}   Right: {"id": 3}

Result

$.email: missing on right

This is the signature of a removed field or a permissions change that now filters the attribute out of the response.

Reference

How each reported difference should be read

How each reported difference should be read
Reported differenceMeaningTypical severity
missing on left / missing on rightThe key exists on one side only.High when the field is required by a consumer.
type mismatchThe same path holds different JSON types.High: strict parsers and typed clients fail here.
array length differsCollections have a different number of elements.Medium: often paging, filtering, or ordering.
value comparisonSame path and type, different primitive value.Low to high depending on whether the field is volatile.

Practical Guide

How teams use JSON Compare

Common use cases

  • Spot missing keys, changed types, or restructured data between a working and a failing response.
  • Review schema drift during API migrations and staged rollouts.
  • Document meaningful payload changes for QA notes or a post-incident write-up.

Checks before trusting the result

  • Both documents must parse before a comparison is possible.
  • Decide in advance which fields are volatile so their differences do not distract from real regressions.
  • Treat a missing optional key differently from a missing required key in your own downstream logic.

Troubleshooting

Common mistakes and how to fix them

Comparing a pretty-printed capture with a compact one and expecting whitespace differences.
Whitespace is invisible to a structural comparison by design. Use it precisely because formatting is irrelevant.
Assuming array differences mean data loss.
Check ordering first. Two arrays with the same members in a different order are reported as several value differences.
Diffing responses captured at different times and blaming the deploy.
Filter out clocks, identifiers, and cursors before drawing a conclusion, or capture both sides in the same window.

FAQ

JSON Compare questions, answered

Does key order affect the result?

No. JSON objects are unordered collections of members, so reordering keys produces no differences at all.

How are arrays compared?

By index. Element zero on the left is compared with element zero on the right, so an inserted first element shifts everything and produces many differences.

Is null treated as a missing key?

No, and the distinction matters. A key with a null value exists and is explicitly empty; a missing key was never sent. APIs frequently assign different meanings to the two.

Why does the list stop after a certain number of entries?

The comparison caps the reported differences so a completely unrelated pair of documents does not produce thousands of lines. Fix the top entries and run it again.

Can I compare very large payloads?

Yes, within the memory available to the browser tab. For multi-megabyte captures it is usually faster to narrow both documents to the subtree you actually care about.

Go deeper

Specifications and guides