Repository navigation
v0.2.0
v0.2.0
New Features
CLI for comparing JSON objects and files
deep-obj-diff now ships with a command-line interface. Compare JSON files or inline strings directly from your terminal.
# Compare two JSON files
deep-obj-diff old.json new.json
# Compare inline JSON
deep-obj-diff '{"a":1,"b":2}' '{"a":1,"b":3,"c":4}'
# Use any output format
deep-obj-diff old.json new.json --format patchCLI features:
- Dual input modes — pass file paths or inline JSON strings
- All output formats —
list(default),flat,nested,patch,json - Rich options —
--include-unchanged,--max-depth,--no-array-order,--filter,--json - Colorized output — respects
NO_COLORandFORCE_COLORenvironment variables - CI-friendly — exits with code
1when differences are found,0when identical - Modular structure — CLI code organized into
src/cli/(types, colors, input, printers, command)
Expand JSON-stringified strings (--expand-json-strings / -e)
String values containing valid JSON can now be recursively expanded before diffing, so their inner structure is compared rather than the raw string.
CLI:
deep-obj-diff old.json new.json -eProgrammatic:
import { diff } from 'deep-obj-diff';
diff(
{ data: '{"name":"Alice"}' },
{ data: '{"name":"Bob"}' },
{ expandJsonStrings: true }
);
// => [{ kind: 'changed', path: 'data.name', lhs: 'Alice', rhs: 'Bob' }]The expandJsonStrings utility function is also exported for standalone use.
Bug Fixes
- CI: build before test — fixed CI failure where CLI tests couldn't find
dist/cli/index.jsbecause tests ran before the build step - Windows compatibility — fixed
npm testscript failing on Windows by replacingnode node_modules/.bin/jestwithnpx jest
Other Changes
- Added 27 new tests (113 total, all passing)
- Updated README with full CLI documentation
- Coverage thresholds maintained (>80% across all metrics)
Install
npm install deep-obj-diff
# Or install globally for CLI access
npm install -g deep-obj-diff