Compare Python JSON Online

Paste two Python JSON objects (dicts or lists). See what was added, removed, or changed — key by key.

🔒 100% private — runs entirely in your browser

or try sample data

What is Python JSON Diff?

Python JSON Diff compares two JSON objects — typically Python dicts serialized with json.dumps() — and shows you exactly which keys were added, removed, or modified. Unlike a simple == check that returns only True or False, this tool gives you a detailed, color-coded breakdown of every change.

Python's built-in json module (json.loads() and json.dumps()) handles serialization, but provides no diff capability. Libraries like deepdiff fill that gap programmatically, and this tool gives you the same insight instantly in your browser — no pip install required.

Paste your JSON objects (e.g., Flask/Django config dicts, API responses, or database records). The tool handles nested structures, arrays, nulls, and mixed types. Everything runs client-side — your data never leaves your machine.

Python JSON Comparison — Code Examples

Using json.loads() with equality check

import json json_a = '{"name": "Alice", "age": 30, "active": true}'
json_b = '{"name": "Alice", "age": 31, "active": true}' obj_a = json.loads(json_a)
obj_b = json.loads(json_b) print(obj_a == obj_b) # False — but which key changed? # Manual key-by-key check
for key in set(list(obj_a.keys()) + list(obj_b.keys())): if obj_a.get(key) != obj_b.get(key): print(f"{key}: {obj_a.get(key)} -> {obj_b.get(key)}")
# age: 30 -> 31

Equality checks tell you if something changed but not what. Manual iteration works for flat dicts but breaks with nesting.

Deep comparison with deepdiff

from deepdiff import DeepDiff config_old = { "database": {"host": "localhost", "port": 5432}, "debug": True, "features": ["auth", "logging"]
}
config_new = { "database": {"host": "db.prod.internal", "port": 5432}, "debug": False, "features": ["auth", "logging", "caching"]
} diff = DeepDiff(config_old, config_new)
print(diff)
# {'values_changed': {"root['database']['host']": ...},
# 'iterable_item_added': {"root['features'][2]": 'caching'}}

DeepDiff handles nested structures but requires pip install deepdiff. This online tool gives you the same insight instantly.

Recursive dict comparison function

def diff_dicts(d1, d2, path=""): for key in set(list(d1.keys()) + list(d2.keys())): p = f"{path}.{key}" if path else key if key not in d1: print(f"ADDED {p}: {d2[key]}") elif key not in d2: print(f"REMOVED {p}: {d1[key]}") elif isinstance(d1[key], dict) and isinstance(d2[key], dict): diff_dicts(d1[key], d2[key], p) elif d1[key] != d2[key]: print(f"CHANGED {p}: {d1[key]} -> {d2[key]}") diff_dicts( {"a": 1, "b": {"c": 2}}, {"a": 1, "b": {"c": 3}, "d": 4}
)
# CHANGED b.c: 2 -> 3
# ADDED d: 4

A simple recursive approach. Doesn't handle arrays or type mismatches — use deepdiff or this tool for full coverage.

Python JSON Comparison Gotchas

Dict key ordering

Python dicts are insertion-ordered since 3.7, but JSON object key order is not guaranteed by the spec. Two JSON strings with the same keys in different order will produce equal dicts after json.loads(). Don't rely on string comparison (json_a == json_b) — always compare parsed objects.

None maps to null

Python's None serializes to JSON null, and json.loads() converts null back to None. This mapping is transparent, but be aware that json.dumps({"a": None}) produces {"a": null}, not {"a": "None"}.

Tuples silently become arrays

json.dumps((1, 2, 3)) produces [1, 2, 3] — tuples are converted to JSON arrays. When you load the JSON back, you get a list, not a tuple. This means a round-trip through JSON changes your data types without warning.

Frequently Asked Questions

How do I compare two Python JSON objects online?

Paste your JSON objects into the two panels and click Compare. The tool highlights added, removed, and modified keys with color-coded diffs.

Can I compare nested Python dicts as JSON?

Yes. The tool performs deep comparison of nested objects, arrays, and mixed structures at any depth. Nested changes are shown with path-based highlighting.

What is the difference between json.loads() comparison and deepdiff?

json.loads() with == only tells you if two objects are equal or not. deepdiff (and this tool) show exactly which keys changed, were added, or were removed — including nested paths.

Is my Python JSON data safe?

Yes. This tool runs entirely in your browser using client-side JavaScript. Your data is never sent to any server, making it safe for comparing sensitive configuration or API data.

Does this handle Python None values in JSON?

Yes. Python None maps to JSON null. The tool correctly compares null values across nested structures and highlights changes involving null.

Can I compare Python dataclass output as JSON?

Yes. Serialize your dataclass with json.dumps(asdict(obj)) and paste the result. The tool compares all fields structurally.