Skip to main content

🔍 JSON Schema Diff

logo.webp

A powerful, intelligent library for comparing JSON schemas with beautiful formatted output, smart parameter combination, and contextual information.

Tests Coverage Python PyPI - Package Version License BlackCode mypy Discord Telegram

⭐ Star us on GitHub | 📚 Read the Docs | 🐛 Report Bug

✨ Features

  • 🎯 Intelligent Comparison - Detects and categorizes all types of schema changes
  • 🎨 Beautiful Output - Colored, formatted differences with clear symbols
  • 🔗 Smart Combination - Combines related parameters (e.g., minimum + maximum = range)
  • 📍 Context Aware - Shows related fields for better understanding (e.g., type + format)
  • 🔄 Semantic Array Diff - Ignores pure reorder noise and reports only real adds/removes/changes
  • ⚡ High Performance - Efficient algorithms for large schemas
  • 🛠️ CLI & Python API & Sphinx Extension - Use programmatically or from command line or in .rst
  • 🔧 Highly Configurable - Customize behavior for your needs

🚀 Quick Start

Installation

# Standard installation
pip install jsonschema-diff

30-Second Example

from jsonschema_diff import JsonSchemaDiff, ConfigMaker
from jsonschema_diff.color import HighlighterPipeline
from jsonschema_diff.color.stages import (
    MonoLinesHighlighter, ReplaceGenericHighlighter, PathHighlighter
)

prop = JsonSchemaDiff(
    config=ConfigMaker.make(),
    colorize_pipeline=HighlighterPipeline([
        MonoLinesHighlighter(),
        ReplaceGenericHighlighter(),
        PathHighlighter(),
    ])
)

prop.compare(
    old_schema="context.old.schema.json",
    new_schema="context.new.schema.json"
)

prop.print(with_legend=True)

Output: ./assets/example_working.svg

Why It Beats Line-Based Diffs For Schemas

For array-like schema parts, this library performs a semantic diff:

  • Pure reorder does not create noisy changes
  • dict elements are matched by structure (not by position)
  • Scalar elements are matched by value multiplicity (multiset logic)

Example:

[1, 2, 3] -> [3, 1, 2, 1]

A line-based diff typically reports multiple moved lines. jsonschema-diff reports just one meaningful change: + 1.

CLI Usage

# Compare schema files
jsonschema-diff schema_v1.json schema_v2.json

# No colors (for logs/CI) and with exit-code
jsonschema-diff --no-color --exit-code schema_v1.json schema_v2.json

# Compare JSON strings
jsonschema-diff "{\"type\":\"string\"}" "{\"type\":\"number\"}"

Sphinx Extension

Use the extension in your build:

extensions += ["jsonschema_diff.sphinx"]

You must also configure the extension. Add the following variable to your conf.py:

from jsonschema_diff import ConfigMaker, JsonSchemaDiff
from jsonschema_diff.color import HighlighterPipeline
from jsonschema_diff.color.stages import (
    MonoLinesHighlighter, PathHighlighter, ReplaceGenericHighlighter,
)

jsonschema_diff = JsonSchemaDiff(
    config=ConfigMaker.make(),
    colorize_pipeline=HighlighterPipeline(
        [MonoLinesHighlighter(), ReplaceGenericHighlighter(), PathHighlighter()],
    ),
)

After that, you can use it in your .rst files:

.. jsonschemadiff:: path/to/file.old.schema.json path/to/file.new.schema.json # from folder `source`
    :name: filename.svg # optional
    :title: Title in virtual terminal # optional
    :no-legend: # optional

📊 Output Format

Symbol Meaning Color Example
+ Added 🟢 Green + ["new_field"].field: "string"
- Removed 🔴 Red - ["old_field"].field: "string"
r Changed 🔵 Cyan r ["field"].field: "old" -> "new"
m Modified 🔵 Cyan m ["field"]: ...
Context ⚪ None ["related"]: "unchanged"

🏗️ Architecture

Modern 6-stage pipeline for clean, testable code:

┌─────────────┐    ┌───────────────┐    ┌──────────────────┐
│ DiffFinder  │───▶│ CompareFinder │───▶│ CombineProcessor │
└─────────────┘    └───────────────┘    └──────────────────┘
                                                  ▼
┌─────────────┐    ┌───────────────┐      ┌───────────────┐
│  Formatter  │◀───│RenderProcessor│◀─────│ DiffProcessor │
└─────────────┘    └───────────────┘      └───────────────┘
  1. DiffFinder: Finds raw differences
  2. CompareProcessor: Find class-processors
  3. Combiner: Combines related parameters
  4. RenderProcessor: Adds context information and render
  5. Formatter: Beautiful colored output

🛠️ Development

Setup

git clone https://github.com/Miskler/jsonschema-diff.git
cd jsonschema-diff
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
make build
make install-dev

Commands

# Checks
make test          # Run tests with coverage
make lint          # Lint code
make type-check    # Type checking  
# Action
make format        # Format code
make docs          # Build documentation

📚 Documentation

🤝 Contributing

We welcome contributions!

Quick Contribution Setup

# Fork the repo, then:
git clone https://github.com/your-username/jsonschema-diff.git
cd jsonschema-diff
# Install
make build
make install-dev
# Ensure everything works
make test
make lint
make type-check

📄 License

MIT License - see LICENSE file for details.

Made with ❤️ for developers working with evolving JSON schemas

Metadata

Release files for jsonschema-diff 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema-diff 0.1.11
File Size Uploaded
jsonschema_diff-0.1.11.tar.gz 44.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema-diff 0.1.11
File Interpreter ABI Platform
jsonschema_diff-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 94.8 kB

Release files / jsonschema_diff-0.1.11.tar.gz

Download URL jsonschema_diff-0.1.11.tar.gz
Size 44.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c3b12f9955ef405d1a7be2909b9ac0b3cdde5f9b7aff20d712bf186b8a36ddad
BLAKE2b-256 checksum
How to use checksums
e164692c8cdab5bfb59d7a7236bd4f814e6e3397bead2e9cb2f01b5036bbf0c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release files / jsonschema_diff-0.1.11-py3-none-any.whl

Download URL jsonschema_diff-0.1.11-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a85e4ad11fea5ab9cfa24938d992dbdee9f861aebb2cef3aa6c02d486c408b8
BLAKE2b-256 checksum
How to use checksums
2697ceab5c2a44ad4238b6143310728b2c063db71f364919f828f6ffdefb05a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page