Two versions of the same JSON document sit before you: the config from before the deploy and the config after, the payload a client sent and the payload you expected. The files are hundreds of lines long, the formatting differs, and somewhere inside them a value changed. Reading both files line by line looking for it is slow and unreliable, because most of the visible difference is layout, not data.

A structural comparison ignores the layout and reports only the data differences, each one pinned to its path. This guide explains how to read that list, the two behaviours that surprise everyone the first time, and how to do it with the free JSON Diff Checker on Ovatly, which runs in your browser and uploads nothing.

Contents

  • Quick answer
  • Structural comparison vs text comparison
  • How to read the difference list
  • Reading skill one: formatting is invisible
  • Reading skill two: arrays compare by index
  • Type changes collapse to one entry
  • How to compare two JSON files, step by step
  • Worked example: one change and one addition
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

To compare two JSON files: paste the original document on the left and the new document on the right in the JSON Diff Checker, press Compare, and read the list of differences. Each entry names a path and says whether a value was added, removed or changed, with the old and new values side by side. Key order and formatting are ignored, so a merely reformatted file shows no differences. If either side is invalid JSON, the tool names the side and the parse problem instead of producing a partial diff.

Structural comparison vs text comparison

A text diff compares lines. Reformat a JSON document, moving every key onto its own line, and a text diff lights up as if everything changed, when in data terms nothing changed at all. JSON is not really lines; it is a tree of objects, arrays and values, and the layout is decoration.

A structural diff compares the tree. Objects are matched by key name, wherever the key sits in the object. Values are compared as values: the number 32 is different from the number 31, but 1 written as 1.0 is the same number and reports no difference. Strings, booleans and null compare by their content. The result is a list of differences that are all real, which is the entire point of comparing data instead of text.

How to read the difference list

Every entry in the list carries a path: the route through the tree to the value that differs. Entries come in three kinds. Added means the path exists in the new document and not in the original. Removed means the reverse. Changed means both sides have the path but the values differ, and the entry shows the old value and the new value side by side so you can judge the change without opening either file.

Read the list top to bottom and you have the complete account of how the two documents differ: nothing outside the list differs, and everything inside it does. That completeness is what makes it trustworthy for reviewing a config change or verifying what a client sent.

Reading skill one: formatting is invisible

Because the comparison is structural, anything that changes only the presentation reports nothing. Reordering keys inside an object: no difference. Reformatting from one line to indented lines, or the reverse: no difference. Writing 1 as 1.0: no difference.

This invisibility is a feature, but you have to trust it. When a comparison comes back empty and you expected changes, the likely explanation is that the documents really do hold the same data and differ only in dress. If a change you made does not appear, check that you pasted the version you think you pasted.

Reading skill two: arrays compare by index

Arrays are ordered lists, and the JSON Diff Checker compares them position by position: item 0 against item 0, item 1 against item 1. Extra items at the end of an array are reported cleanly as added or removed. The surprise comes with an insertion in the middle. Add one item at position 1 and every later item shifts by one place, so each of them now sits opposite a different partner and is reported as changed, followed by the final item reported as added.

That run of changed entries is the honest consequence of positional comparison, and once you know to expect it, it reads correctly: a block of consecutive changes inside one array usually means one insertion or deletion upstream, not many separate edits. If order does not matter for a particular array, treat such a run as a prompt to check for a shift before concluding the data was heavily edited.

Type changes collapse to one entry

When a value changes its type, for example an object replaced by a plain string, the diff reports one changed entry at that path rather than exploding the old object into a removal for every key it held. This keeps the list readable: the entry says the value at that path changed from an object to a string, and that is the fact you need. If you want the detail of what the old object contained, it is in the original document, one lookup away.

How to compare two JSON files, step by step

  1. Open the JSON Diff Checker.
  2. Paste the original JSON on the left and the new JSON on the right. Keeping the direction straight matters, because added and removed are defined relative to it.
  3. Press Compare.
  4. Read the list of added, removed and changed paths, with old and new values side by side.
  5. Fix either document and compare again if needed, until the list shows the differences you intended and no others.

Worked example: one change and one addition

Suppose the original document is a small record:

{"name":"Ana","age":31}

The new version reads:

{"name":"Ana","age":32,"city":"Lisbon"}

The comparison reports exactly two entries:

CHANGED age: 31 -> 32
ADDED city: "Lisbon"

The name is absent from the list because it did not change. Age is a single changed entry with both values shown. City is an addition with its new value. Two entries are the whole story of how these documents differ, and no amount of reformatting either file would add a third.

Limitations and honest tradeoffs

The comparison needs both sides to be valid JSON. If one side fails to parse, the tool says which side failed and why, and produces no partial diff. That is the right refusal: a partial list would look complete while hiding differences in the unparsed region.

Arrays, as covered above, compare by index, so order changes inside an array are reported as value changes at each affected position rather than as moves. And the diff reports what changed, never why: it cannot tell a deliberate edit from an accident, which is why the list belongs in a review, with a human reading it.

Common mistakes

  • Pasting the documents the wrong way round. Added and removed swap meaning if the original is on the right. Keep the older document on the left.
  • Reading a run of array changes as many edits. A mid-array insertion shifts every later item. Check for a shift first.
  • Expecting formatting changes to appear. They never do. The comparison is structural by design.
  • Treating an empty result as a tool failure. Empty means the data is identical, however different the files look.
  • Comparing an invalid document and expecting a partial answer. Fix the parse error on the named side first, then compare again.

FAQs

Does key order matter when comparing JSON? No. Objects are compared by key name, not by position, so a document whose keys were reordered, or which was simply reformatted, shows zero differences against the original.

How are arrays compared? By index: item 0 against item 0, item 1 against item 1, and so on. Extra items at the end are reported as added or removed, but inserting an item in the middle shifts the later items, so they are reported as changed.

What happens if one of the files is invalid JSON? The comparison stops. The tool says which side failed to parse and why, and it does not produce a partial diff, because a half-compared result would hide exactly the differences you came to find.

Is 1 versus 1.0 reported as a change? No. Numbers that are equal in value but written differently are the same JSON number, so 1 and 1.0 show no difference.

Is anything uploaded for the comparison? No. Both documents are parsed and compared in your browser, so config files and payloads you paste never leave your device.

Conclusion

A good JSON comparison answers one question completely: what data changed, and where. The JSON Diff Checker answers it with a path-by-path list, ignoring the formatting noise that makes text diffs useless on data files. When the job is the opposite one, shrinking a single document rather than comparing two, our guide to minifying JSON covers the whitespace-only trim and its byte readout. For more guides in this series, see our Data and JSON Tools guides.

References