JsonDiffPatch compares JavaScript object graphs and produces deltas for patch, unpatch, and reverse operations. It ships HTML and console formatters and runs in Node 18+ or bundled browsers.
Overview
JsonDiffPatch deep-compares plain JavaScript objects and arrays, emitting a compact delta format you can apply with patch or roll back with reverse. An included clone helper performs deep copies without going through JSON serialization.
Output formatters render visual HTML diffs, annotated JSON explanations, colored console output, or raw delta JSON. Array diffing matches items by key, id, or name fields when available, and long strings use character-level text diffing via diff-match-patch.
The npm package is ESM-only and targets Node.js 18 or newer. A public demo site compares JSON online, and npx jsondiffpatch can diff files or URLs from a terminal.
Plugin pipes let advanced users customize the diff, patch, and reverse pipeline with extra filters.
Key features
- Deep diff with patch and reverse
- HTML, console, and JSON delta formatters
- Smart array diffing by id or key
- Character-level diff for long strings
- jsondiffpatch.clone deep copy helper
- Customizable pipe and filter plugins
Use cases
- Show JSON edits in a web UI
- Version structured config documents
- Compute deltas for audit trails