deep-obj-diff-cli
v1.0.1
Published
CLI for deep-obj-diff — compare two JSON objects or files from the command line
Maintainers
Readme
deep-obj-diff-cli
A command-line tool for comparing JSON objects or files and displaying differences — powered by deep-obj-diff.
Installation
npm install -g deep-obj-diff-cliOr use with npx:
npx deep-obj-diff-cli old.json new.jsonQuick Start
# Compare two JSON files
deep-obj-diff old.json new.json
# Compare inline JSON strings
deep-obj-diff '{"a":1,"b":2}' '{"a":1,"b":3,"c":4}'Common Use Cases
Compare API responses
curl https://api.example.com/v1/config > old.json
curl https://api.example.com/v2/config > new.json
deep-obj-diff old.json new.jsonGenerate JSON Patch output
deep-obj-diff old.json new.json --format patchGet machine-readable JSON (for piping)
deep-obj-diff old.json new.json --json | jq '.[] | select(.kind == "changed")'Compare only a specific subtree
deep-obj-diff old.json new.json --filter settingsTreat arrays as unordered sets
deep-obj-diff old.json new.json --no-array-orderLimit comparison depth
deep-obj-diff old.json new.json -d 2Ignore specific paths
deep-obj-diff old.json new.json -i "*.timestamp" -i "metadata.*"Include unchanged properties
deep-obj-diff old.json new.json -uExpand JSON-stringified values before diffing
deep-obj-diff old.json new.json -eOutput Formats
| Format | Flag | Description |
|--------|------|-------------|
| list | -f list | Colored change list (default) |
| flat | -f flat | Flat object keyed by dot-path |
| nested | -f nested | Nested structure mirroring object shape |
| patch | -f patch | JSON Patch operations (RFC 6902) |
| json | -f json | Raw JSON list output |
All Options
| Flag | Alias | Description |
|------|-------|-------------|
| --format <fmt> | -f | Output format (see above) |
| --include-unchanged | -u | Include unchanged properties |
| --max-depth <n> | -d | Maximum recursion depth |
| --no-array-order | | Treat arrays as unordered sets |
| --filter <prefix> | | Only include paths matching the prefix |
| --ignore <pattern> | -i | Ignore paths (repeatable, supports globs) |
| --expand-json-strings | -e | Expand JSON-stringified values |
| --json | | Raw JSON output (no colors, pipe-friendly) |
| --version | -V | Show version number |
| --help | -h | Show help |
Exit Codes
- 0 — no differences found
- 1 — differences found (useful in CI/CD scripts)
License
MIT
