Skip to main content

HTML-only diff generator for top-level JSON objects

Project description

json-pretty-diff

LinkedIn GitHub Buy Me a Coffee

Made with love by Javier Lianes García in Aranjuez ❤️

This project is stable. Bug fixes will be released as issues are reported.

Overview

Generate a clean HTML report that summarizes the top-level differences between two JSON files. The report groups keys into Added, Removed, and Changed sections to make the impact of the updates easy to scan.

Installation

From PyPI (recommended)

  1. Ensure Python 3.9 or newer is available on your system.
  2. Install the package:
    pip install json-pretty-diff
    
  3. Run the CLI to compare two JSON files:
    jpd original.json updated.json -o diff.html
    
  4. Open diff.html in your browser to explore the report.

From source

  1. Clone this repository.
  2. Install the package in editable mode:
    pip install -e .
    

Usage

Run the command-line tool and point it to the files you want to compare:

jpd A.json B.json -o diff.html

Options

Flag Description
-o, --output Path to the output HTML file. When omitted, HTML is printed to stdout.
--open Open the generated HTML report in the default browser (requires -o).
-q, --quiet Suppress all output except errors.
--no-style Generate HTML without CSS styles (lighter output).
--version Show program version and exit.

Exit codes

  • 0: no differences were detected (an HTML report is still generated showing "No differences").
  • 1: differences were found and the HTML describes every change.
  • 2: an error occurred (missing file, invalid JSON, or a root element that is not a JSON object) and no HTML report is produced.

Example

jpd fixtures/base.json fixtures/update.json -o reports/diff.html

The file diff.html will contain one section per change category with simple styles that highlight added, removed, or modified keys.

Limitations

  • Only the first-level keys are compared (no recursive diff).
  • There are no exclusions, tolerances, or advanced configuration flags.
  • Console output never uses ANSI colors.
  • There is no CI/CD integration or bundled automated test suite.

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

json_pretty_diff-1.1.1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

json_pretty_diff-1.1.1-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file json_pretty_diff-1.1.1.tar.gz.

File metadata

  • Download URL: json_pretty_diff-1.1.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for json_pretty_diff-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e540fdd9ac0974bb64dbe0891b8a63333dd64044982fbffa535ad6e6826721fb
MD5 fd089d221b935dd75f5f47b79347cc7b
BLAKE2b-256 f7954644d49bf75ebb938b9f0e9e89ada7b3700c3ce839a0a6c3b49524483638

See more details on using hashes here.

File details

Details for the file json_pretty_diff-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for json_pretty_diff-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6c9f54dc19e93d3807b6ec924d866d7c4849cb79dd5c02dc60df1ed47e286ec
MD5 50bc8168b681361e52aa9d52ea4f78ca
BLAKE2b-256 f6181fddc099376f15ef8d0de0dcfe62f1952d29cb4a2c2d14db2e95fb18237e

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