@chengyixu/json-diff
v1.0.0
Published
Diff two JSON files/streams with colored terminal output — zero dependencies
Maintainers
Readme
json-diff
Diff two JSON files or streams with colored terminal output. Zero dependencies, single file.
Install
npm install -g @chengyixu/json-diffUsage
# Compare two files
json-diff old.json new.json
# Compare stdin against a file
cat data.json | json-diff - expected.json
# Sort keys before comparing (ignores key order)
json-diff --sort old.json new.json
# Compact mode (hide unchanged values)
json-diff --compact old.json new.jsonFlags
| Flag | Short | Description |
|------|-------|-------------|
| --help | -h | Show help |
| --version | -v | Print version |
| --sort | -s | Sort object keys before comparing |
| --compact | -c | Compact output |
| --indent <n> | | JSON indentation (default: 2) |
Output colors
- Green — added keys/values
- Red — removed keys/values
- Yellow — changed values
- Cyan — string values
- Bold — key paths
Examples
# Compare API responses
curl -s https://api.example.com/v1/status | json-diff - expected.json
# Prettified large diff
json-diff --indent 2 --sort old.json new.jsonLicense
MIT
