By JSONConvert Team··5 min read
Comparing JSON Objects: Find API Differences
You changed something in your API and need to verify the response still looks right. Or you're debugging why staging returns different data than production. You need to compare two JSON objects and see exactly what changed.
Why JSON Diff Matters
JSON comparison comes up constantly in development:
- API testing: Compare expected vs actual responses
- Debugging: What changed between two API calls?
- Code review: What does this config change actually affect?
- Migration validation: Does the new system produce the same output?
- Monitoring: Detect unexpected changes in webhook payloads
Deep vs Shallow Comparison
A shallow comparison (JSON.stringify(a) === JSON.stringify(b)) fails for:
- Key ordering:
{"a":1,"b":2}and{"b":2,"a":1}are semantically equal but stringify differently - Formatting: Indentation and whitespace differences
- Nested changes: No information about what specifically changed
- Added keys: Present in B but not A
- Removed keys: Present in A but not B
- Changed values: Same key, different value
- Type changes: e.g.,
"123"(string) vs123(number)
How JSON Diff Works
The algorithm walks both objects simultaneously:
The result shows the exact path to each difference:
Practical Examples
Comparing API versions
Diff result:
$.user.email: changed from "ada@v1.io" to "ada@v2.io"$.user.role: added ("admin")$.metadata: added (new object)
Config file changes
Compare before and after a deployment config change to verify only intended fields changed.
Using the JSON Diff Tool
Our JSON diff tool makes comparison easy:
- Paste the first JSON in the left panel
- Paste the second JSON in the right panel
- Differences are highlighted instantly with color coding:
The comparison runs entirely in your browser. Your JSON data is never sent to any server.
Tips for Effective Diffing
- Format both inputs first. Use our JSON formatter to normalize indentation before comparing.
- Check for semantic equality. Two JSON objects with different key order are the same data.
- Watch for type coercion.
"1"(string) and1(number) are different in JSON. - Use the path output. When reporting bugs, include the exact JSONPath to the difference.