What Is JSON Diff?
JSON diff compares two JSON objects and shows exactly what changed between them — which keys were added, which were removed, and which values changed. Unlike a plain text diff that compares raw characters line by line, a semantic JSON diff understands the structure.
The key advantage: two JSON objects can have keys in completely different orders and still be semantically identical, because key order has no meaning in JSON. A text diff would show them as completely different; a JSON diff shows them as equal.
How JSONKit JSON Diff Works
Open JSONKit's JSON Diff tool. Paste the original (before) JSON in the left panel and the modified (after) JSON in the right panel. The diff runs automatically as you type:
- Green — key was added (exists in the right/new version, not in the left/original)
- Red — key was removed (exists in left/original, not in right/new)
- Orange — key exists in both but the value changed (shows old value → new value)
If the two JSON objects are semantically identical, a "No differences" confirmation appears. Only differences are shown by default; toggle "Show unchanged" to see the full object with changes highlighted inline.
Deep Comparison — Nested Changes Are Pinpointed
The diff engine is fully recursive. If a single field changes deep inside a 10-level nested object, only that specific key path is shown:
Changed: user.address.city
"Surat" → "Ahmedabad"
Added: user.metadata.lastLoginAt
"2025-06-01T10:30:00Z"
Removed: user.legacyIdYou never have to scan the entire object to find what changed.
Practical Use Cases
API response testing: Paste the before and after response from a staging/production deploy to verify that only the expected fields changed — no surprise data mutations.
Configuration management: Diff two versions of a JSON config file to audit what settings changed between deployments, across environments, or between branches.
Database record auditing: Export the before and after state of a record and diff them to find exactly which fields were modified. Useful for compliance, debugging, and change tracking.
Code review: Paste old and new JSON fixture files to produce a readable summary of changes for pull request reviews.
Contract testing: Compare an API response against the expected contract JSON to catch schema drift before it hits production.
Format Both and Swap
Format Both — beautifies both panels before comparing. Use this when one paste comes from a minified API response and the other from a formatted file.
Swap — reverses which JSON is treated as the original and which as the modified version. Useful when you accidentally pasted them in the wrong order.
JSON Diff in JavaScript
A recursive deep diff implementation:
function diffObjects(left, right, prefix = "") {
const changes = [];
const allKeys = new Set([...Object.keys(left), ...Object.keys(right)]);
for (const key of allKeys) {
const fullKey = prefix ? `${prefix}.${key}` : key;
if (!(key in left)) {
changes.push({ type: "added", key: fullKey, value: right[key] });
continue;
}
if (!(key in right)) {
changes.push({ type: "removed", key: fullKey, value: left[key] });
continue;
}
const lv = left[key], rv = right[key];
if (typeof lv === "object" && lv !== null &&
typeof rv === "object" && rv !== null &&
!Array.isArray(lv) && !Array.isArray(rv)) {
// Recurse into nested objects
changes.push(...diffObjects(lv, rv, fullKey));
} else if (JSON.stringify(lv) !== JSON.stringify(rv)) {
changes.push({ type: "changed", key: fullKey, left: lv, right: rv });
}
}
return changes;
}
// Usage
const changes = diffObjects(
JSON.parse(originalJson),
JSON.parse(modifiedJson)
);
changes.forEach(c => console.log(c.type.toUpperCase(), c.key));JSON Diff in Python
def diff_json(left, right, prefix=""):
changes = []
all_keys = set(list(left.keys()) + list(right.keys()))
for key in all_keys:
full_key = f"{prefix}.{key}" if prefix else key
if key not in left:
changes.append({"type": "added", "key": full_key, "value": right[key]})
elif key not in right:
changes.append({"type": "removed", "key": full_key, "value": left[key]})
elif isinstance(left[key], dict) and isinstance(right[key], dict):
changes.extend(diff_json(left[key], right[key], full_key))
elif left[key] != right[key]:
changes.append({"type": "changed", "key": full_key,
"left": left[key], "right": right[key]})
return changes
import json
changes = diff_json(json.loads(original_json), json.loads(modified_json))
for c in changes:
print(c["type"].upper(), c["key"])Diff Libraries
If you need JSON diff in a production codebase:
| Language | Library | Notes |
|---|---|---|
| JavaScript | deep-diff | Returns a structured change list with path arrays |
| JavaScript | fast-json-diff | Produces RFC 6902 JSON Patch output |
| Python | deepdiff | Rich output with type change detection |
| Go | github.com/r3labs/diff | Struct-aware deep comparison |
| CLI | jq | jq -n --argjson a "$a" --argjson b "$b" '...$a,$b' for manual comparison |
Use JSONKit's JSON Diff tool for instant browser-based comparison — no library install, no CLI, paste and see results immediately.