Compare two JSON files quickly using Python standard library.
Project description
quick-json-diff
A fast JSON diff tool built entirely with the Python standard library — no third-party dependencies required.
Recursively compare two JSON objects and produce a structured list of all differences (added, removed, or modified values), each annotated with a clear dot-notation path.
Features
- Zero dependencies — powered by Python standard library only
- Recursive comparison — drill into nested dicts and lists automatically
- Clear path output — each difference includes a dot-notation / bracket-notation path (e.g.,
variables[3].spec.sort) - Three diff kinds —
added,removed,modifiedfor every change - CLI + Python API — use it from the command line or as a library
- Safe & predictable — pure Python dataclass output, easy to serialise
Installation
python -m pip install quick-json-diff
Usage
CLI
json-diff <left_json_file> <right_json_file>
Example:
json-diff test_left.json test_right.json
Output:
[
{
"path": "variables[3].spec.sort",
"kind": "modified",
"left": "alphabeticalAsc123",
"right": "alphabeticalAsc"
}
]
Python API
import json
from quick_json_diff import JsonDiffer
left = JsonDiffer.read_json("test_left.json")
right = JsonDiffer.read_json("test_right.json")
differ = JsonDiffer(left, right)
result = differ.diff()
print(json.dumps(result, ensure_ascii=False, indent=2))
You can also work with raw Python objects directly:
from quick_json_diff import JsonDiffer
left = {"a": 1, "b": [1, 2, 3]}
right = {"a": 2, "b": [1, 2, 3, 4], "c": "new"}
differ = JsonDiffer(left, right)
result = differ.diff()
for item in result:
print(f"{item['kind']}: {item['path']}")
if item['left'] is not None:
print(f" left: {item['left']}")
if item['right'] is not None:
print(f" right: {item['right']}")
Output:
modified: a
left: 1
right: 2
added: c
right: new
added: b[3]
right: 4
Output Format
differ.diff() returns a list[dict]. Each dict has the following keys:
| Key | Type | Description |
|---|---|---|
path |
str |
Dot/bracket-notation path to the value |
kind |
"added" / "removed" / "modified" |
Type of change |
left |
Any (optional) |
Original value (present for removed / modified) |
right |
Any (optional) |
New value (present for added / modified) |
The same shape is available as the DiffResult dataclass:
from quick_json_diff import DiffResult
result: DiffResult # .path, .kind, .left, .right
Contributing
Contributions are welcome! Here's how you can help:
- Report issues — open a GitHub Issue for bugs or feature requests
- Submit pull requests — fork the repo, make changes, and open a PR
- Development setup:
git clone https://github.com/rainuxhe/fastjsondiff.git cd quick-json-diff pip install -e ".[dev]" python -m build
Before submitting, please ensure the existing tests pass and add tests for new functionality.
License
MIT © 2026 Rainux He
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quick_json_diff-1.0.0.tar.gz.
File metadata
- Download URL: quick_json_diff-1.0.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1d7592b18f4e1ab76ff560c8f3c569185f1c0b0e14c065f770a66c2cc77bcf7
|
|
| MD5 |
6199d62c40f2ca64e6b354f78795ab10
|
|
| BLAKE2b-256 |
fe500baccaa16d9af384164e0e1e57fd890927f10f9401e13e53f798e6830541
|
File details
Details for the file quick_json_diff-1.0.0-py3-none-any.whl.
File metadata
- Download URL: quick_json_diff-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e77ed82cec8f1a39d802ca3b65b81b65a7a62b6767d40b8647cbb4bbc0690a9e
|
|
| MD5 |
3af2ae5458979ea2ea7056a48ad4c557
|
|
| BLAKE2b-256 |
780f82a1893b355980fe2599e275edbb21e658b9b7a1f9aafa85acbd5e9ac203
|