Skip to main content

Compare two JSON files quickly using Python standard library.

Project description

quick-json-diff

Python License PyPI version PyPI downloads

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 kindsadded, removed, modified for 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:

  1. Report issues — open a GitHub Issue for bugs or feature requests
  2. Submit pull requests — fork the repo, make changes, and open a PR
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quick_json_diff-1.0.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quick_json_diff-1.0.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

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

Hashes for quick_json_diff-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a1d7592b18f4e1ab76ff560c8f3c569185f1c0b0e14c065f770a66c2cc77bcf7
MD5 6199d62c40f2ca64e6b354f78795ab10
BLAKE2b-256 fe500baccaa16d9af384164e0e1e57fd890927f10f9401e13e53f798e6830541

See more details on using hashes here.

File details

Details for the file quick_json_diff-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quick_json_diff-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e77ed82cec8f1a39d802ca3b65b81b65a7a62b6767d40b8647cbb4bbc0690a9e
MD5 3af2ae5458979ea2ea7056a48ad4c557
BLAKE2b-256 780f82a1893b355980fe2599e275edbb21e658b9b7a1f9aafa85acbd5e9ac203

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page