You have two API responses from the same endpoint. One works and one doesn’t. Each has about 600 lines of JSON, and somewhere inside is the value that is wrong.
You can paste both into a normal text diff checker, but the result is often a mess of red and green. One file may have its keys in a different order, or different spacing. None of that is a real difference. It only hides the one change you are looking for.
Why a text diff is hard to use for JSON
JSON is data, not plain text. Two files can mean exactly the same thing and still look very different. For example:
{ "name": "Ada", "role": "admin" }
{
"role": "admin",
"name": "Ada"
}
Both are the same object. A line-by-line diff will say every line changed. A JSON-aware comparison will say nothing changed, which is the correct answer.
What a good JSON comparison does
- It ignores formatting. Spaces, indentation and line breaks do not matter.
- It ignores key order. An object has no order, so the comparison should not care about it either.
- It shows where the change is. Instead of “line 212 is different,” you see a path like
user.address.postcode, so you know which field changed. - It shows the type of change. A value can be added, removed or changed. A number that became a string is a different problem from a missing field, and you should be able to tell them apart.
How to compare two JSON files
Here are the steps with our JSON compare tool:
- Paste or drop the first JSON on the left and the second one on the right.
- Run the comparison.
- Read the changes by path. Each one shows the old value and the new value.
- If you need to apply the changes somewhere else, export the result as a JSON Patch.
The tool runs in your browser, so you can paste real responses without worry. This matters because API responses often contain tokens, emails and customer data.
The array problem
Arrays are the trickiest part of comparing JSON. Here is a list of users:
[{ "id": 1, "name": "Ada" }, { "id": 2, "name": "Linus" }]
Suppose the second file has the same two users in the opposite order. Is that a change? Technically, yes, because arrays have an order. In practice, usually no. You want the two items matched by their id, so the result says “nothing changed” or “Linus’s name changed,” instead of “both items were replaced.”
That is why it helps to use a tool that can match array items by a key such as id. If your array order really matters, for example a list of steps, keep the default and let the order count. For a plain list of values, such as names or IDs, the list diff checker is a simpler fit. If your data lives in a spreadsheet, try the Excel and CSV diff checker.
Common reasons two JSON files are different
- A field is missing in one environment because of a setting or a feature flag.
- A number is a string in one response (
"42"instead of42). It looks the same on screen but behaves differently in code. nullin one file and a missing key in the other. Many systems treat these differently.- Timestamps or generated IDs that change on every request. These always show up as differences, so you can look past them.
- Small rounding differences in decimal numbers, such as
0.1and0.10000000000000001.
A simple routine for debugging
When something works in one environment and fails in another, try this:
- Get the response from both, using the same input.
- Compare them by meaning, not as plain text.
- Set aside the fields you expect to be different, such as timestamps and IDs.
- What remains is your list of suspects. It is usually short.
Summary
A JSON diff is only useful if it ignores the things that don’t matter. Compare by meaning, match array items by id when it makes sense, and keep your data on your own device. Then the one wrong value is much easier to find.