Skip to content

chengyixu/json-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

json-diff

Diff two JSON files or streams with colored terminal output. Zero dependencies, single file.

Install

npm install -g @chengyixu/json-diff

Usage

# 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.json

Flags

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.json

License

MIT

About

Diff two JSON files/streams with colored terminal output — zero dependencies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors