Skip to content

JSON Diff

Compares two JSON documents structurally, ignoring key order and reporting added, removed and changed paths.

Compares two JSON documents structurally rather than as text, so a reordered key or different indentation is not a difference. The output is both a readable table of what changed and an RFC 6902 patch that turns the left document into the right one exactly.

🔒 Runs entirely in your browserjsondiffcompare
Arrays

Line the two arrays up first, so one insertion is one change rather than a hundred.

Left

Right

How to use it

  1. Paste both documents

    Two API responses, two configs, a before and an after. The comparison runs in a worker and updates as you type.

  2. Choose how arrays are compared

    This is the setting that decides whether the result is useful. Align lines the two arrays up first, so inserting one element is one change. By index compares position for position, which is right when the order is the data. By key matches elements on a named member — the answer when two responses list the same things in a different order.

  3. Decide whether null means absent

    Some serialisers omit an empty field and some write `null`. If you are comparing output from two different stacks, turning this on removes a page of false differences.

  4. Take the table, or take the patch

    The table is for reading; the patch is for applying. Paths in both are RFC 6901 pointers, so they paste into any tool that speaks JSON Patch.

Common questions

Why does one inserted array element show as a hundred changes?

Because the array mode is By index, so element 1 is being compared with element 2 and everything shifts. Switch to Align, which lines the arrays up first, or to By key if the elements have an id.

Can I apply the patch here?

No, this page only produces it. But the patch is exact: applying it to the left document yields the right one byte for byte in the data model, and that round trip is what the test suite asserts on every change.

It says the two documents are not related.

That message appears when the comparison passes twenty thousand changes and stops. At that point the diff is not telling you anything useful — you are comparing two different documents rather than two versions of one.

Does key order ever matter?

Not to this tool — JSON objects are unordered, so two documents that differ only in key order are reported as identical. If key order matters to your consumer, that consumer is relying on something JSON does not promise.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.