Skip to content
Rushabh5000Public

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-diff

Zero dependencies Node License: MIT Platform

Semantic JSON differ that understands JSON structure — shows added, removed, and changed keys with color. Zero dependencies.

Unlike diff, it understands JSON. Unlike jsondiffpatch, it needs no dependencies.


Install

npm install -g json-diff

Or without installing:

npx json-diff a.json b.json

Example Output

json-diff  old.json  →  new.json
  4 change(s): +2  -1  ~1

  + user.address.zip
       "10001"
  - user.phone
       "555-1234"
  ~ user.age
       28  →  29
  ~ config.features
       ["search","export"]  →  ["search","export","import"]

Usage

json-diff a.json b.json              # Human-readable diff
json-diff a.json b.json --patch      # RFC 6902 JSON Patch output
json-diff a.json b.json --quiet      # Exit 1 if different, no output (CI)
json-diff a.json b.json --count      # Print number of changes

Output Symbols

Symbol Meaning
+ Key/value added in B
- Key/value removed (was in A)
~ Value changed
! Type changed (e.g. string → number)

JSON Patch Output (--patch)

Outputs RFC 6902 compatible JSON Patch:

[
  { "op": "add",     "path": "/user/address/zip", "value": "10001" },
  { "op": "remove",  "path": "/user/phone" },
  { "op": "replace", "path": "/user/age", "value": 29 }
]

CI Integration

- name: Ensure config unchanged
  run: json-diff config.json config.expected.json --quiet

Exit code is 1 if any differences are found, 0 if identical.


License

MIT


Keywords

json diff · compare json · json compare · json patch · rfc 6902 · diff json files · semantic json diff · json change detection · zero dependencies · cli


Built to solve, shared to help — Rushabh Shah 🛠️✨

One of 40+ zero-dependency developer CLI tools — no node_modules, ever.

Releases

Packages

Contributors

Languages