TL;DR: Get production-ready results in 1 HTTP call. No signup, no credit card, no rate limit.
Free JSON Diff API - Compare JSON Objects & Detect Structure Changes
Comparing JSON responses manually is error-prone. You need to detect added keys, removed keys, modified values, type changes, nested structure differences. Libraries like deepdiff help, but parsing and formatting results is tedious. What if you could compare JSON via REST API and get structured diffs instantly?
The JSON Diff API compares two JSON objects and returns detailed differences: added fields, deleted fields, value changes, type mismatches, nested object differences. Perfect for API response validation, schema evolution tracking, database migration verification, and configuration management.
Why Use This API?
JSON diffing matters:
- API Testing – Verify responses match expected structure
- Schema Evolution – Track when API responses change
- Data Migration – Verify old vs. new data matches
- Configuration Management – Detect config changes
- Debugging – Compare expected vs. actual responses
- Compliance – Track data modifications for audit logs
Quick Example - cURL
# Compare two JSON objects
curl -X POST "https://json-diff-api.p.rapidapi.com/compare" \
-H "X-RapidAPI-Key: YOUR_KEY" \
-H "X-RapidAPI-Host: json-diff-api.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{
"json1": {"name": "Alice", "age": 30, "city": "NYC"},
"json2": {"name": "Alice", "age": 31, "country": "USA"}
}'
Response:
{
"success": true,
"differences": [
{
"type": "modified",
"path": "age",
"old_value": 30,
"new_value": 31
},
{
"type": "added",
"path": "country",
"value": "USA"
},
{
"type": "removed",
"path": "city",
"value": "NYC"
}
],
"changes_count": 3
}
Python Example
import requests
import json
url = "https://json-diff-api.p.rapidapi.com/compare"
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "json-diff-api.p.rapidapi.com",
"Content-Type": "application/json"
}
# Compare API responses
expected_response = {
"status": "success",
"data": {"user_id": 123, "email": "user@example.com"},
"timestamp": 1704067200
}
actual_response = {
"status": "success",
"data": {"user_id": 123, "email": "user@example.com", "verified": True},
"timestamp": 1704067201,
"version": "2.0"
}
payload = {
"json1": expected_response,
"json2": actual_response
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(f"API response has {data['changes_count']} changes:")
for diff in data["differences"]:
if diff["type"] == "added":
print(f" ✚ Added: {diff['path']} = {diff['value']}")
elif diff["type"] == "removed":
print(f" ✖ Removed: {diff['path']}")
elif diff["type"] == "modified":
print(f" ↻ Changed: {diff['path']} ({diff['old_value']} → {diff['new_value']})")
JavaScript / Node.js Example
const axios = require("axios");
const compareJSON = async (json1, json2) => {
const response = await axios.post(
"https://json-diff-api.p.rapidapi.com/compare",
{ json1, json2 },
{
headers: {
"X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
"X-RapidAPI-Host": "json-diff-api.p.rapidapi.com"
}
}
);
return response.data;
};
// Test API response schema
const testAPIResponse = async () => {
const expected = {
id: "user_123",
name: "John Doe",
email: "john@example.com",
created_at: "2024-01-01"
};
const actual = await fetch("/api/users/123").then(r => r.json());
const diffs = await compareJSON(expected, actual);
if (diffs.changes_count === 0) {
console.log("✓ API response matches expected schema");
} else {
console.log("✗ API response has unexpected changes:");
diffs.differences.forEach(d => {
console.log(` ${d.type}: ${d.path}`);
});
}
};
Change Types
| Type | Meaning | Example |
|---|---|---|
| added | Key exists in json2 but not json1 |
"new_field": true added |
| removed | Key exists in json1 but not json2 |
"old_field" removed |
| modified | Value changed but key exists in both | "age": 30 → 31 |
| type_changed | Value type differs | "count": 5 → "5" |
| nested | Difference in nested object | Recursively compared |
Real-World Use Cases
1. API Response Validation Testing
Assert that API responses match expected structure.
def test_user_endpoint():
response = requests.get("/api/users/123").json()
expected = {
"id": 123,
"name": "Test User",
"email": "test@example.com"
}
diffs = compare_json(expected, response)
# Fail test if unexpected changes
assert diffs["changes_count"] == 0, f"Response mismatch: {diffs}"
2. Database Migration Verification
Verify old and new database data match after migration.
def verify_migration():
old_record = db_old.query("SELECT * FROM users WHERE id=1")
new_record = db_new.query("SELECT * FROM users WHERE id=1")
diffs = compare_json(old_record, new_record)
if diffs["changes_count"] > 0:
log_migration_error(diffs)
3. Configuration Change Tracking
Detect when configurations change, log for audit.
def update_config(config_updates):
old_config = load_config()
new_config = {**old_config, **config_updates}
diffs = compare_json(old_config, new_config)
# Log configuration changes for compliance
audit_log.add({
"timestamp": now(),
"changes": diffs["differences"],
"user": current_user()
})
save_config(new_config)
4. API Schema Evolution Tracking
Monitor when API response schemas change.
def track_api_schema_change():
current_response = get_api_response()
baseline = load_schema_baseline()
diffs = compare_json(baseline, current_response)
if diffs["changes_count"] > 0:
notify_team("API schema has changed!", diffs)
update_schema_baseline(current_response)
5. Clone Verification
Verify data cloning/replication is successful.
def verify_data_clone(source_id, clone_id):
source = db.get_record(source_id)
clone = db.get_record(clone_id)
# Compare all fields except ID and timestamp
source_copy = {k: v for k, v in source.items() if k not in ["id", "created_at"]}
clone_copy = {k: v for k, v in clone.items() if k not in ["id", "created_at"]}
diffs = compare_json(source_copy, clone_copy)
assert diffs["changes_count"] == 0, "Clone data mismatch!"
6. Version Comparison
Track differences between API versions.
def compare_versions(v1_response, v2_response):
diffs = compare_json(v1_response, v2_response)
breaking_changes = [d for d in diffs["differences"] if d["type"] in ["removed", "type_changed"]]
if breaking_changes:
print("Breaking changes detected in v2:")
for change in breaking_changes:
print(f" - {change['path']}")
Pricing
| Plan | Cost | Requests/Month | Best For |
|---|---|---|---|
| Free | $0 | 500 | Development, testing |
| Pro | $5.99 | 50,000 | API testing suites |
| Ultra | $14.99 | 500,000 | Enterprise validation |
Related APIs
- Text Diff API – Compare text/code instead of JSON
- Regex Tester API – Validate JSON with regex
- String Utilities API – Process JSON strings
- API Validation Tools – Schema validation
Get Started Now
No credit card. 500 free requests to detect JSON differences.
Testing APIs with complex responses? Share your validation strategy in the comments!
Top comments (0)