jpprint
Side-by-side JSON comparison tool with color-coded diff indicators.
Features
- Side-by-side comparison with intelligent line alignment
- Color-coded diffs: Red (deletions), Green (additions), Yellow (modifications)
- Unicode box-drawing with beautiful visual separators (│ and ◆)
- Pure Python - no external dependencies, stdlib only
- Python 3.10+ with modern type hints
Installation
pip install jpprint
Quick Start
from jpprint import jpprint
base = {"name": "Alice", "age": 30, "city": "NYC"}
updated = {"name": "Alice", "age": 31, "city": "Boston"}
jpprint(base, updated)
Output (with colors and Unicode box characters):
{ │ {
"age": 30, ◆ "age": 31,
"city": "NYC", ◆ "city": "Boston",
"name": "Alice" │ "name": "Alice"
} │ }
Usage
from jpprint import jpprint
# Compare two JSON objects
left = {"a": "b", "c": "d"}
right = {"a": "b", "c": "changed"}
jpprint(left, right)
# Format single object
jpprint({"user": "alice", "role": "admin"})
# Return as list instead of printing
output = jpprint(left, right, retr=True)
# Show only differences
jpprint(left, right, diff_only=True)
# Disable colors for plain text
jpprint(left, right, use_colors=False)
# Use ASCII characters instead of Unicode
jpprint(left, right, use_box_chars=False)
# Disable intelligent alignment
jpprint(left, right, align_lines=False)
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
align_lines |
bool | True |
Intelligently align matching lines using difflib |
diff_ind |
str | <> |
Indicator for different lines (ignored if use_box_chars=True) |
diff_only |
bool | False |
Show only lines that differ |
indent |
int | 4 |
JSON indentation spaces |
max_width |
int | None |
Truncate lines to max width |
retr |
bool | False |
Return output instead of printing |
separator |
str | | |
Column separator for equal lines (ignored if use_box_chars=True) |
show_ln |
bool | False |
Display line numbers |
use_box_chars |
bool | True |
Use Unicode box-drawing characters (│, ◆) |
use_colors |
bool | True |
Enable/disable color output |
Advanced Examples
Comparing API Responses
import requests
from jpprint import jpprint
v1 = requests.get("https://api.example.com/v1/user/123").json()
v2 = requests.get("https://api.example.com/v2/user/123").json()
jpprint(v1, v2)
Nested JSON Structures
config_old = {
"database": {"host": "localhost", "port": 5432},
"cache": {"enabled": True}
}
config_new = {
"database": {"host": "db.example.com", "port": 5432},
"cache": {"enabled": True, "ttl": 3600}
}
jpprint(config_old, config_new)
Datetime and UUID Support
from datetime import datetime
import uuid
data = {
"user": "alice",
"id": uuid.uuid4(),
"created_at": datetime(2024, 1, 1, 12, 0, 0)
}
jpprint(data)
# Automatically converts datetime to ISO format and UUID to string
How It Works
jpprint uses Python's difflib.SequenceMatcher to intelligently align matching lines side-by-side, making it easy to spot additions, deletions, and modifications in JSON data. Color coding and Unicode box characters provide clear visual indicators of changes.
Development
Setup
git clone https://github.com/voidnologo/jpprint.git
cd jpprint
pip install -e ".[dev]"
Running Tests
python run_tests.py
Code Quality
ruff format . # Format code
ruff check . # Check linting
isort . # Sort imports
Requirements
- Python 3.10 or higher
- No external runtime dependencies
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for jpprint 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jpprint-2.0.3.tar.gz | 10.7 kB | Without provenance | Details for jpprint-2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jpprint-2.0.3-py3-none-any.whl | Python 3 | none | any | Details for jpprint-2.0.3-py3-none-any.whl |
Total release size: 18.3 kB
Release files / jpprint-2.0.3.tar.gz
| Download URL | jpprint-2.0.3.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a39e93895422a354bbcf0943a53d37158e9a1e5228f889b996d4ced0c6858db4
|
|
BLAKE2b-256 checksum How to use checksums |
9044f793b5f2e254e80e04dd6d6d725d20d06e5b11325eeb6943f33c1d8586fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / jpprint-2.0.3-py3-none-any.whl
| Download URL | jpprint-2.0.3-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf04ed8bf645fe7336e52d2f35f3c814370a8004615c5184d269b880a91785e2
|
|
BLAKE2b-256 checksum How to use checksums |
48ef90c7eb08aae32438f2392bd4c07ab9fe7072e674a1eac1a48f8ff0c895c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for jpprint 2.0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.