npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chengyixu/json-diff

v1.1.0

Published

Compare JSON files with beautiful structural diffs — color-coded output, JSON Patch (RFC 6902), unified diff, JSONL support, and streaming parser

Readme

jsondiff-cli

Compare two JSON files and show structural differences — additions, deletions, type changes, and value changes with colored terminal output.

Install

npm install -g jsondiff-cli

Or run directly:

npx jsondiff-cli file1.json file2.json

Usage

# Compare two files
jsondiff old.json new.json

# Output as JSON (for piping/scripting)
jsondiff --format json old.json new.json > diff.json

# Show only additions and removals
jsondiff --filter added,removed config-v1.json config-v2.json

# Compare only a specific subtree
jsondiff --path "$.dependencies" package-old.json package-new.json

# Quiet mode for CI/CD (exit code 1 if different, 0 if identical)
jsondiff --quiet a.json b.json && echo "identical" || echo "different"

# Read from stdin
cat data.json | jsondiff - expected.json

# Compact output (one line per change)
jsondiff --format compact a.json b.json

Output Example

── Added ──
  + $.dependencies.axios: "1.6.0"
  + $.scripts.test: "jest"

── Removed ──
  - $.dependencies.lodash: "4.17.21"

── Changed ──
  ~ $.version: "1.0.0" → "1.1.0"
  ~ $.dependencies.express: "4.18.0" → "4.19.0"

── Type Changed ──
  ! $.count: string → number

7 differences: 2 added, 1 removed, 2 changed, 1 type changed

Features

  • Structural diff — deep comparison of nested objects and arrays
  • Type change detection — catches when "5" becomes 5 or an array becomes an object
  • JSONPath output — every change shows its exact location (e.g., $.config.database.host)
  • Multiple formats — colored text, JSON, or compact one-liner output
  • Path filtering — compare only a subtree (e.g., --path "$.dependencies")
  • Type filtering — show only additions, removals, changes, or type changes
  • Quiet mode — perfect for CI/CD scripts (exit code based)
  • Stdin support — pipe JSON from other commands
  • Programmatic API — import and use in your own Node.js code

Programmatic API

import { diff, summarize, formatText } from 'jsondiff-cli';

const changes = diff(obj1, obj2);
const summary = summarize(changes);
console.log(formatText(changes, summary));

Options

| Option | Description | |---|---| | -f, --format <type> | Output format: text, json, compact (default: text) | | --filter <types> | Comma-separated change types: added, removed, changed, type_changed | | --path <prefix> | Only show changes under this JSONPath prefix | | --no-color | Disable colored output | | -v, --verbose | Show old/new values for type changes | | -q, --quiet | No output, exit code only (1=different, 0=identical) |

Exit Codes

| Code | Meaning | |---|---| | 0 | Files are identical (or --quiet mode, no differences) | | 1 | Differences found | | 2 | Error (file not found, invalid JSON, etc.) |

License

MIT