{"_id":"@chengyixu/jsondiff","name":"@chengyixu/jsondiff","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@chengyixu/jsondiff","version":"1.0.0","description":"Compare two JSON files and show structural differences — additions, deletions, type changes, and value changes with colored output","type":"module","main":"dist/index.js","bin":{"jsondiff":"dist/cli.js"},"scripts":{"build":"tsc","prepublishOnly":"npm run build"},"keywords":["json","diff","compare","cli","structural-diff","json-compare","developer-tools","devtools","configuration","config-diff"],"author":{"name":"Wilson Xu","email":"chengyixu@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/chengyixu/jsondiff-cli.git"},"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.11.0"},"dependencies":{"chalk":"^5.3.0","commander":"^12.1.0"},"engines":{"node":">=18"},"types":"./dist/index.d.ts","_id":"@chengyixu/jsondiff@1.0.0","bugs":{"url":"https://github.com/chengyixu/jsondiff-cli/issues"},"homepage":"https://github.com/chengyixu/jsondiff-cli#readme","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-tQ0pL4mrndgOimLMolU/S8l8UO6JjOeLwue/nO+Y6IJSZW9iD2fHISXNQ3Jyy/+tauLc00jb7AJ1gFCUgojLUA==","shasum":"9dea423bcfd34f4d32fc89765151612f779ac775","tarball":"https://registry.npmjs.org/@chengyixu/jsondiff/-/jsondiff-1.0.0.tgz","fileCount":16,"unpackedSize":32619,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHmXG+OVkWHKsSJyNW9xxHX8qVCStFcMI8Ldp5vteemHAiEA91QU8cwQSiVm53YHA8gG5kCGhGCh6OinmhjVNWu71e4="}]},"_npmUser":{"name":"chengyixu","email":"Chengyi_xu@outlook.com"},"directories":{},"maintainers":[{"name":"chengyixu","email":"Chengyi_xu@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jsondiff_1.0.0_1773980116596_0.9358845219525906"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-20T04:15:16.536Z","1.0.0":"2026-03-20T04:15:16.731Z","modified":"2026-03-20T04:15:16.899Z"},"maintainers":[{"name":"chengyixu","email":"Chengyi_xu@outlook.com"}],"description":"Compare two JSON files and show structural differences — additions, deletions, type changes, and value changes with colored output","homepage":"https://github.com/chengyixu/jsondiff-cli#readme","keywords":["json","diff","compare","cli","structural-diff","json-compare","developer-tools","devtools","configuration","config-diff"],"repository":{"type":"git","url":"git+https://github.com/chengyixu/jsondiff-cli.git"},"author":{"name":"Wilson Xu","email":"chengyixu@gmail.com"},"bugs":{"url":"https://github.com/chengyixu/jsondiff-cli/issues"},"license":"MIT","readme":"# jsondiff-cli\n\nCompare two JSON files and show structural differences — additions, deletions, type changes, and value changes with colored terminal output.\n\n## Install\n\n```bash\nnpm install -g jsondiff-cli\n```\n\nOr run directly:\n\n```bash\nnpx jsondiff-cli file1.json file2.json\n```\n\n## Usage\n\n```bash\n# Compare two files\njsondiff old.json new.json\n\n# Output as JSON (for piping/scripting)\njsondiff --format json old.json new.json > diff.json\n\n# Show only additions and removals\njsondiff --filter added,removed config-v1.json config-v2.json\n\n# Compare only a specific subtree\njsondiff --path \"$.dependencies\" package-old.json package-new.json\n\n# Quiet mode for CI/CD (exit code 1 if different, 0 if identical)\njsondiff --quiet a.json b.json && echo \"identical\" || echo \"different\"\n\n# Read from stdin\ncat data.json | jsondiff - expected.json\n\n# Compact output (one line per change)\njsondiff --format compact a.json b.json\n```\n\n## Output Example\n\n```\n── Added ──\n  + $.dependencies.axios: \"1.6.0\"\n  + $.scripts.test: \"jest\"\n\n── Removed ──\n  - $.dependencies.lodash: \"4.17.21\"\n\n── Changed ──\n  ~ $.version: \"1.0.0\" → \"1.1.0\"\n  ~ $.dependencies.express: \"4.18.0\" → \"4.19.0\"\n\n── Type Changed ──\n  ! $.count: string → number\n\n7 differences: 2 added, 1 removed, 2 changed, 1 type changed\n```\n\n## Features\n\n- **Structural diff** — deep comparison of nested objects and arrays\n- **Type change detection** — catches when `\"5\"` becomes `5` or an array becomes an object\n- **JSONPath output** — every change shows its exact location (e.g., `$.config.database.host`)\n- **Multiple formats** — colored text, JSON, or compact one-liner output\n- **Path filtering** — compare only a subtree (e.g., `--path \"$.dependencies\"`)\n- **Type filtering** — show only additions, removals, changes, or type changes\n- **Quiet mode** — perfect for CI/CD scripts (exit code based)\n- **Stdin support** — pipe JSON from other commands\n- **Programmatic API** — import and use in your own Node.js code\n\n## Programmatic API\n\n```js\nimport { diff, summarize, formatText } from 'jsondiff-cli';\n\nconst changes = diff(obj1, obj2);\nconst summary = summarize(changes);\nconsole.log(formatText(changes, summary));\n```\n\n## Options\n\n| Option | Description |\n|---|---|\n| `-f, --format <type>` | Output format: `text`, `json`, `compact` (default: `text`) |\n| `--filter <types>` | Comma-separated change types: `added`, `removed`, `changed`, `type_changed` |\n| `--path <prefix>` | Only show changes under this JSONPath prefix |\n| `--no-color` | Disable colored output |\n| `-v, --verbose` | Show old/new values for type changes |\n| `-q, --quiet` | No output, exit code only (1=different, 0=identical) |\n\n## Exit Codes\n\n| Code | Meaning |\n|---|---|\n| `0` | Files are identical (or `--quiet` mode, no differences) |\n| `1` | Differences found |\n| `2` | Error (file not found, invalid JSON, etc.) |\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-c1edb93c7cb056b5597b30f87de79085"}