A powerful, intelligent library for comparing JSON schemas with beautiful formatted output, smart parameter combination, and contextual information.
β Star us on GitHub | π Read the Docs | π Report Bug
- π― 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) - β‘ 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
# Standard installation
pip install jsonschema-difffrom 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)# 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\"}"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| 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" |
Modern 6-stage pipeline for clean, testable code:
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
β DiffFinder βββββΆβ CompareFinder βββββΆβ CombineProcessor β
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
βΌ
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β Formatter ββββββRenderProcessorββββββββ DiffProcessor β
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
- DiffFinder: Finds raw differences
- CompareProcessor: Find class-processors
- Combiner: Combines related parameters
- RenderProcessor: Adds context information and render
- Formatter: Beautiful colored output
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# 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# 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-checkMIT License - see LICENSE file for details.
Made with β€οΈ for developers working with evolving JSON schemas