← All guides

JSON comparison guide

How to Compare JSON API Responses

Compare two JSON API responses with a worked example. Find changed, added, and removed fields, understand array order, and reduce timestamp noise.

When a release changes an API response, a line-by-line diff can bury the useful changes under indentation and reordered fields. A structural comparison helps you locate the values that changed, then decide whether those differences are expected.

Compare JSON responses

Capture both responses

Collect the baseline and updated responses under the same request conditions. Keep the endpoint, query parameters, authentication scope, and test data consistent so unrelated differences do not hide the change you need to find.

Format and validate first

Paste the response body, without HTTP headers or log prefixes. Use the JSON Formatter if you need help finding syntax errors. Both inputs must be valid JSON; single-quoted strings, comments, and trailing commas are not valid JSON.

Compare two JSON responses: a worked example

Open JSON Compare, paste this first document into Original, and paste the second into Updated. Select Compare. These fictional records show an account upgrade and a product price change.

Original response

{
  "user": { "id": 42, "plan": "free" },
  "active": true,
  "legacyCode": "A1",
  "items": [{ "sku": "keyboard", "price": 49 }]
}

Updated response

{
  "user": { "id": 42, "plan": "pro" },
  "active": true,
  "items": [{ "sku": "keyboard", "price": 59 }],
  "region": "us"
}

Expected differences

The unchanged ID, active flag, and SKU do not appear in the differences. Changing a value is not automatically an error: check the endpoint’s contract and the expected outcome of the release.

Read differences by object path

The $ marks the document root. A dot leads into an object field, and [0] means the first array element. For example, $.items[0].price locates the price inside the first item. Removed fields may break consumers that require them; added fields may require updates to strict response validators.

Does JSON key order matter?

For ordinary objects with unique field names, changing key order or whitespace does not change the values this tool compares. You do not need to sort object keys first. The JSON specification describes objects as unordered name/value collections.

Why do reordered arrays show differences?

Arrays preserve order. This tool compares array elements by position, not by a matching ID or SKU. If the same records arrive in a different order, you may see many changed paths even when the records themselves are unchanged.

If your API contract treats the list as an unordered set, sort both lists by the same stable, unique field before pasting them. If the order has meaning, such as ranked search results or event history, keep it intact. JSON Compare does not automatically sort arrays or match records by ID.

How do I ignore timestamps and request IDs?

Repeated calls often produce new timestamps, request IDs, or generated identifiers. Keep the original responses for reference, then remove only those known volatile fields from copies before comparing. The tool currently has no ignore-fields setting. Do not remove a field if its change is what you are investigating.

Is null the same as a missing field?

No. A field set to null is still present. Removing that field produces a removal, while changing it from null to a string produces a changed value. Likewise, a number such as 42 and the string "42" have different types and are reported as different values.

Common comparison workflows

For a complete debugging workflow, follow the REST API testing guide to capture responses, compare the bodies here, and check the status codes and headers separately. A JSON diff compares data; it does not establish that the API meets its full contract.

Compare two payloads

See added, removed, and changed JSON values with their exact paths.

Open JSON Compare