jsondiffpatch is a library for computing diffs and applying patches to JavaScript objects.
The tool solves the problem of tracking changes between two versions of a JavaScript object by computing a delta—a compact representation of what changed. It uses longest common subsequence matching for arrays, allowing smart comparison of array elements when an objectHash function is provided to identify which objects correspond across versions. For long strings, it optionally applies character-level diffing. The delta can then be used to patch an object forward to a new state or reversed to revert it to a previous state.
Developers should choose this tool when they need to track object mutations compactly, such as in collaborative editing, undo/redo systems, or change logging. It works well for projects that serialize state as JSON and need to transmit or store only the differences rather than full snapshots. The library produces multiple output formats including a compact JSON delta format, visual HTML diffs, RFC 6902 JSON Patch format, and colored console output. At roughly 16KB minified and gzipped, it is lightweight enough for browser use. The tool requires providing an objectHash function when diffing arrays of objects to achieve meaningful results; without it, array comparison falls back to position-based matching.
The project maintains active continuous integration on its master branch. Development activity shows consistent engagement with the codebase through regular updates and testing infrastructure.