Command-line wrapper around json-difference. Computes the delta between two JSON strings and prints it to stdout.
Global (recommended for CLI use):
npm install -g json-difference-cli
# or
yarn global add json-difference-cliOne-off:
npx json-difference-cli -o "{}" -m '{"a":1}'jd -o <original-json> -m <modified-json>| Flag | Alias | Required | Description |
|---|---|---|---|
-o |
--original |
yes | Original (old) JSON string |
-m |
--modified |
yes | Modified (new) JSON string |
# Simple key change
jd -o '{"a":"b"}' -m '{"a":"c"}'
# delta ---> { added: [], removed: [], edited: [ [ 'a', 'b', 'c' ] ] }
# Added / removed keys
jd -o '{"a":1}' -m '{"b":2}'
# delta ---> { added: [["b", 2]], removed: [["a", 1]], edited: [] }
# Root type change
jd -o '{}' -m '[]'
# delta ---> { added: [], removed: [], edited: [["__root__", {}, []]] }JSON uses double quotes, so on macOS/Linux wrap the argument in single quotes:
jd -o '{"foo":"bar"}' -m '{"foo":"baz"}'On Windows PowerShell, escape the inner quotes or use single quotes:
jd -o '{\"foo\":\"bar\"}' -m '{\"foo\":\"baz\"}'The tool prints the delta returned by getDiff:
{
added: [[path, value], ...],
removed: [[path, value], ...],
edited: [[path, oldValue, newValue], ...]
}See the json-difference README for the full path format and semantics.
json-difference— the underlying library (use directly in code)mcp-json-diff— MCP server for AI agents
- Repository: https://github.com/lukascivil/json-difference
- Issues: https://github.com/lukascivil/json-difference/issues
- Changelog
MIT © lukascivil