pythonjsonformatter

How to compare two API JSON responses

Find the fields that changed between two responses without being distracted by indentation or object key order.

A response before and after an API release may differ in only one nested field. Reading both as raw text is slow, especially if a server changes formatting or property order. A JSON comparison focuses on the data rather than its layout.

Capture the original and updated responses

Copy the response bodies, not HTTP headers or log prefixes, into the Original content and Updated content fields of Diff Checker. Both sides must be valid JSON for a structural comparison. You can use JSON Viewer first to inspect a large nested response and fold branches you do not need.

Consider these two response bodies:

Original

{"user":{"id":42,"plan":"basic"},"features":["export"]}

Updated

{"features":["export","audit"],"user":{"id":42,"plan":"pro"}}

Click Check differences. The property order changed, but that alone is not reported. The checker finds an added value at $.features[1] and a changed value at $.user.plan. The path tells you where the change occurred; the result shows the value on each side.

Decide whether each change is expected

Added means the updated response has a key or array position the original lacked. Removed means the reverse. Changed means the same location has a different value or type, such as a number becoming a string. Review those changes against the API contract rather than treating every difference as an error.

Response metadata such as a request ID or timestamp can change on every call. If you only care about stable business fields, compare a consistent subset of each response. Keep the original copies elsewhere if you need an audit trail; editing the paste changes what the checker can report.

Check array positions carefully

Objects are compared by key, but arrays are compared by index. If a list is reordered, the checker may report changes at several positions even when the same records are still present. Check an identifier such as id or sku before deciding whether a record was modified. The JSON specification treats object members as unordered and array entries as ordered.

What if one response is not valid JSON?

Diff Checker automatically uses a line comparison when either side cannot be parsed as JSON. That still helps you spot a changed error page, log message, or malformed response, but it no longer reports JSON paths. The result status shows Text rather than JSON. If you expected paths, check for a missing comma, unquoted property name, or extra text around the response body.

When an optional field changes, distinguish a missing property, null, and an empty value before applying defaults to either response.

By Python JSON Formatter ·