Compare JSON API Responses to Debug Changes
When an API behavior changes, the fastest way to find out what happened is to compare the old response against the new one. But JSON is structured data — a plain text diff will flag every reformatted line, even if the values are the same. You need a diff that understands JSON structure.
DiffLab's JSON Compare tool parses both inputs as JSON objects and compares them field by field. Added fields are highlighted in green, removed fields in red, and modified values in orange — regardless of key ordering or whitespace.
Step-by-step: comparing two API responses
Imagine your API previously returned this user object:
{
"id": 42,
"name": "Alice",
"email": "alice@example.com",
"role": "member",
"active": true
}
After a recent deploy, the response now looks like this:
{
"id": 42,
"name": "Alice",
"email": "alice@newdomain.com",
"role": "admin",
"active": true,
"createdAt": "2026-01-15T00:00:00Z"
}
Paste both into the JSON Compare tool. DiffLab highlights:
email: modified fromalice@example.comtoalice@newdomain.comrole: modified frommembertoadmincreatedAt: added (new field)
Fields like id, name, and active are unhighlighted because they did not change. This is far more useful than a line diff, which would flag every line as "changed" if the JSON was reformatted.
Tree view vs text view
DiffLab's JSON Compare offers two visualization modes:
- Tree view: Renders the JSON as an expandable tree. Useful for deeply nested objects with arrays and multiple levels. You can collapse branches you don't care about and focus on the differences.
- Text view: Shows the JSON in a side-by-side line format, similar to a code diff. Better for flat objects or when you want to see the raw JSON text alongside the highlights.
Common debugging scenarios
Detecting a breaking API change
Capture the response from your staging environment and from production. Paste them in. If a field was renamed or removed, it appears as a red deletion and a green addition — signaling a potential breaking change for clients that depend on that field.
Verifying a data migration
Export a sample record from the old database and the corresponding record from the new database as JSON. Compare them. Any field that changed during migration is highlighted, so you can verify the migration did not corrupt data.
Regression testing
Save a known-good API response as a JSON file. After a code change, hit the same endpoint and compare the new response against the saved one. Any unexpected field change is immediately visible.
[1, 2, 3] and later returns [3, 2, 1], every element will appear as modified because the diff compares by position, not by value. For unordered comparison of array elements, consider using the List Compare tool instead.
For a deeper comparison of when to use JSON diff versus plain text diff, see JSON Diff vs Text Diff: When to Use Which.
Compare your JSON API responses now.
Open JSON Compare