A test prints a JSON response, and somewhere inside it one value is wrong. The document is two hundred lines long. The baseline from last week is also two hundred lines long, and the two do not line up neatly: keys come out in a different order, numbers print differently, and the one real change hides among a hundred cosmetic ones. So the check gets done by eye, quickly, and the wrong value ships.

A baseline comparison replaces the eyeball with a list. You keep one trusted document, the expected output, and compare every new run against it structurally. The result is not a pass or a fail stamped on the whole document: it is a short list of the exact paths that diverged, with the old and new values. This guide shows how to run that comparison with the free JSON Diff Checker on Ovatly, which works entirely in your browser.

Contents

  • Quick answer
  • Why reading two JSON documents side by side fails
  • What a structural comparison checks, and what it ignores
  • How to compare test output against a baseline, step by step
  • Worked example: a baseline and a changed output
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Keep the expected output as a fixed baseline file. For each new run, open the JSON Diff Checker, put the baseline on one side and the actual output on the other, and read the report: every divergence is listed by path as added, removed or changed, with the old and new values. Key order is ignored and 1 and 1.0 count as the same number, so formatting noise does not fail a good run. If the actual output is invalid JSON, the tool names that side and gives no partial diff, so a broken run fails loudly instead of looking almost right. No entries in the report means the output matches the baseline.

Why reading two JSON documents side by side fails

JSON is text, but the meaning of a JSON document is not in its text layout. Two documents can carry identical data and still look different on screen: the keys of an object can be serialised in any order, whitespace is free, and the same number can be written as 1 or 1.0. A line-by-line text comparison flags all of that as change, which trains you to skim, and skimming is how the one genuine change gets missed.

The opposite failure is just as common. A value deep in a nested object changes from 31 to 32, the surrounding lines look identical, and the eye slides past it. The problem is not carelessness; it is that a human is being asked to do a structural job with a text tool. The fix is to compare the parsed documents, value by value, and let everything that did not change fall out of the report entirely.

What a structural comparison checks, and what it ignores

The checker parses both documents and walks them together, comparing the value at every path. Where the two disagree, it records one of three things: a value that was added, a value that was removed, or a value that changed, shown with its old and new forms. Where they agree, it records nothing, which is why the report stays short even for large documents.

Just as important is what the comparison deliberately ignores. Key order does not matter, because an object is a set of named values, not a sequence. Numbers are compared by value, so 1 and 1.0 are the same number and never appear as a change. And when a value changes type, say from a number to a string, that is reported as one changed entry at that path, not as a removal plus an addition. Arrays are the one place where position is part of the meaning: they are compared by index, first element against first element, and the limitations section below explains what that means for inserted items.

How to compare test output against a baseline, step by step

  1. Capture the expected output once, from a run you have verified by hand, and save it as the baseline. This file is the standard; do not edit it casually.
  2. Open the JSON Diff Checker and put the baseline on one side. Pick a side and always use the same one, so added and removed read consistently from report to report.
  3. Paste the actual output from the latest run on the other side, exactly as the test produced it.
  4. Run the comparison and read the report from top to bottom. Each entry names a path, so you can go straight to the field that diverged instead of searching the document.
  5. Decide on each entry: a bug to fix, or an intended change. Only when a change is intended do you update the baseline, deliberately, so the next run compares against the new standard.

Worked example: a baseline and a changed output

Say the baseline for a small record is this:

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

The latest run produces this:

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

The report contains exactly two entries:

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

Read it literally. The value at the path age was 31 in the baseline and is 32 now: one change to investigate or accept. The path city exists in the new output and did not exist in the baseline: one addition. The name field appears nowhere in the report, because it is identical on both sides, and identical content is never listed. Two entries, two decisions, and nothing else to scan. That is the whole point of comparing against a baseline instead of rereading the full output after every run.

Limitations and honest tradeoffs

If either document is invalid JSON, the tool names that side and produces no partial diff. For a baseline workflow that is the right behaviour, a malformed output should fail as malformed, not produce a misleading half comparison, but it does mean you fix the syntax before you can see any value differences.

Arrays are compared by index, so inserting an element near the start of an array makes the entries after it show as changed, even when the same values are all present, just shifted. For ordered data that is correct and useful. For data that is really a set, expect shift noise and read those entries with the shift in mind.

The checker compares the two documents you give it. It does not run your tests, capture their output, or judge whether the baseline itself is right. A baseline captured from a broken run will faithfully certify broken output, so the one manual verification that matters is the first one.

Common mistakes

  • Updating the baseline before reading the report. That erases the regression you were about to catch. Read first, then decide.
  • Capturing the baseline from an unverified run. The baseline is only as trustworthy as the check you did when you saved it.
  • Switching sides between runs. Added and removed swap meaning when the baseline changes sides, and old reports stop being comparable.
  • Treating an invalid-output result as a tool failure. The tool is telling you the run produced broken JSON. That is the finding.
  • Panicking at array shift noise. If an element was inserted, check whether the array is order-sensitive before treating every shifted entry as a separate bug.

FAQs

Which side should the baseline go on? Either side works mechanically, but the report reads added and removed relative to the two sides, so pick one convention, baseline first is the common one, and keep it for every run. Consistency is what makes reports comparable over time.

My output prints 1.0 where the baseline has 1. Will that fail? No. The comparison treats 1 and 1.0 as the same number, because they are the same value written two ways. Only a real change in value is reported.

What happens if the actual output is not valid JSON? The tool names the side that failed to parse and produces no partial diff. That is deliberate: a broken output fails loudly as invalid, instead of producing a half report that looks almost right.

Does the order of keys in the output matter? No. Key order is ignored, so a run that serialises the same object with its keys in a different order still matches the baseline.

How are arrays compared against the baseline? By index. The first element is compared with the first element, the second with the second, and so on. Inserting an element near the start shifts the entries after it, and those shifts appear as changes.

Conclusion

A baseline turns output checking from a reading exercise into a decision list: a handful of paths, each with its old and new values, and silence everywhere the output held steady. Keep the baseline verified and fixed, keep it on the same side, and let the JSON Diff Checker do the scanning. If the report format itself is new to you, our explainer on reading a JSON diff report walks through each kind of entry in detail. For more guides in this series, see our Data and JSON Tools guides.

References