Open-source project
benjamine/jsondiffpatch avatar
benjamine/jsondiffpatch

jsondiffpatch: the delta format, array matching, and a package stuck on 0.6.0

Diff & patch JavaScript objects

5,354 stars501 forksTypeScriptMIT

At a glance

What is it?
A 16KB TypeScript library that turns two JavaScript values into a delta you can apply, reverse and reformat into HTML, annotated JSON or RFC 6902. For identity matching of objects in arrays, configure an objectHash function.
Who is it for?
The design is focused and the README reports a small footprint. GitHub lists v0.6.0 as a release, while npm publishes later package versions; check the registry and documentation for the version you install.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 27 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • benjamine/jsondiffpatch5,354 ★ · +7
Star history
Repository2026-10-072026-11-24
benjamine/jsondiffpatch5.3k5.4k

7 Stars in the last 48 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

One idea, kept small on purpose

jsondiffpatch answers a narrow question and refuses to widen it. Given two JavaScript values, what is the smallest record of how to turn the first into the second? That record is a delta, a plain JSON object holding only what changed, and the library gives you the tools to produce it, apply it, reverse it, and inspect it. The README states the cost up front as min+gzipped ~ 16KB with browser and server (ESM-only) support, which is a fair baseline in a category where diffing libraries usually arrive with a dependency tree attached.

Installing it is a single package, and the CLI is reachable without installing anything at all:

sh
npm install jsondiffpatch
sh
npx jsondiffpatch --help

The repository is TypeScript, MIT licensed, 5343 stars and 496 forks, on default branch master, not archived, last pushed 2026-10-29, with 54 open issues. The API is correspondingly narrow: diff, patch, unpatch, reverse, clone, create and dateReviver. There is no plugin marketplace, no built-in transport, no opinion about how you persist a delta. The format is the product.

Configuration happens through create, which takes an options object and returns an instance. That indirection is what lets several parts of the same application attach different objectHash functions, array policies or text diff settings without fighting over module state, and it is the difference between a library that embeds in a React app and one that only works in a script. The demo at jsondiffpatch.com is the fastest way to see what a real delta looks like against real documents.

Array diffing is the part that decides whether you trust the output

The README puts this warning in bold italics for good reason: smart array diffing uses LCS, and to match objects inside an array you must provide an objectHash function. Without one, matching falls back to position, which is not a degraded feature so much as a different and mostly wrong answer.

Consider the array example in the README: five Argentine cities, with Cordoba deleted and La Plata added. Moved items are detected because arrays.detectMove defaults to true; otherwise they are registered as remove plus add. Silent and plausible is the dangerous failure mode here.

The detectMove option, default true, controls whether moved items are recognised at all. The tests that pin all of this behaviour are not at the repository root; the README sends you to packages/jsondiffpatch/test/examples for nested objects, arrays and long text diffs, which is the right place to look before trusting an edge case.

Five output formats over a single engine

The delta is computed once and then rendered, which is why the formatter list is so much longer than the algorithm list. The default output is pure JSON in the delta format, described as a low footprint option and documented in docs/deltas.md. From there the same delta can be rendered as an HTML visual diff, as annotated JSON that explains each part of the delta format inline, as RFC 6902 JSON Patch that can be generated and also applied, or as coloured console output that the README shows running as ./node_modules/.bin/jsondiffpatch left.json right.json. The docs at docs/formatters.md cover writing your own.

Long strings get an optional second layer. Text diffing runs at character level through google diff match patch, which you import separately from @dmsnell/diff-match-patch only if you want text diffs.

Dates are handled by dateReviver, which you pass as the reviver to JSON.parse when cloning an object that contains Date instances. The README example clones country with JSON.parse(JSON.stringify(country), jsondiffpatch.dateReviver) so the independence Date survives the clone.

Version 0.6.0 broke six things on purpose

GitHub lists v0.6.0 as a release dated 2023-12-15, but npm has later package versions; check the registry for the version you intend to install. The README describes the package as ESM-only, lists Node.js 18 and 20+ and any browser that supports ES6 as supported platforms, and documents a namespace import of jsondiffpatch.

The repository was pushed to as recently as 2026-10-29. The code on the default branch may differ from a published package, so check the documentation and changes for the installed version.

The monorepo shows where the work moved

The root package.json is short enough to read in full, and it explains the repository layout. It declares npm workspaces covering demos/console-demo, demos/html-demo, demos/numeric-plugin-demo, packages/jsondiffpatch and packages/diff-mcp. Three of those five are demos, which says something about how much of this project is about showing the output rather than producing it. The fifth, packages/diff-mcp, is a separate package for Model Context Protocol exposure, a direction that has nothing to do with the delta format and a great deal to do with where attention in the ecosystem is going.

Only two scripts are declared at the root, and neither runs the tests. lint maps to biome check --error-on-warnings ., so formatting and lint failures are hard errors rather than warnings, and type-check maps to tsc --noEmit. The devDependencies are correspondingly lean, @biomejs/biome at ^1.9.4 and typescript at ^5.8.2. The repository also carries biome.jsonc, tsconfig.json, .editorconfig, .npmrc and .gitignore, which is a modern and tidy setup. That there is no test script at the root is not an oversight so much as a consequence of testing inside packages/jsondiffpatch, but it does mean a contributor has to know where to look.

The two demos beyond console and html earn their place. The structure is coherent, and the one surprise is diff-mcp, which suggests the maintainers see the future of this library as something an agent can call rather than something an application imports.

What the 54 open issues are probably about

With 54 open issues against 5343 stars, this is a mature library with a normal amount of accumulated friction rather than a neglected one. Three themes are likely sources of friction. The first is the ESM boundary. A pure ESM package is a common source of reports from CommonJS consumers and from bundlers that resolve exports maps differently.

The second is array matching, and it is the theme this repository is most exposed on. objectHash is optional and its absence produces a result that looks plausible, so issues may be about a delta that is technically correct and semantically wrong.

The third is dates and other non-JSON types. The library can round trip a Date through dateReviver, but the delta format itself is JSON, so anything not representable in JSON has to be handled either by custom formatters or by accepting that the diff describes what the serialised value looks like rather than what the in-memory value is.

None of this makes the library a poor choice. It is small, focused, MIT licensed, well documented through docs/deltas.md, docs/arrays.md and docs/formatters.md, and tested against example cases that live in a path the README actually points you to. The sharp edges are documented edges, and the two that will cost you the most time are supplying objectHash and pinning the version you actually tested against.

Editorial conclusion

The design is focused and the README reports a small footprint. GitHub lists v0.6.0 as a release, while npm publishes later package versions; check the registry and documentation for the version you install. Two concrete details should decide your approach. First, provide an objectHash function when comparing distinct object instances in arrays by identity; otherwise position-based matching can give misleading results. Second, the root package.json exposes only lint and type-check, so the test suite you would want to lean on lives under packages/jsondiffpatch rather than at the top of the monorepo. Install with npm install jsondiffpatch, pin the version deliberately, and read docs/deltas.md before you rely on the wire format in production.

Frequently asked questions

What is a JSON Patch?

JSON Patch is the format defined in RFC 6902, a list of operations such as add, remove and replace, each pointing at a path inside a document. It is a standard that other systems can apply without knowing anything about jsondiffpatch. This library generates and applies it through the jsonpatch formatter, but that is only one of its output formats.

What's the difference between diff and patch?

Diff takes two values and returns a delta describing the difference between them. Patch takes a delta and applies it to a value. Reverse turns a delta upside down, and unpatch uses a delta to roll a value back to where it started.

What are the key differences between the JSON Patch and JSON merge patch methods?

JSON Patch in RFC 6902 is an operation list with explicit paths, so it can insert, move and reorder without ambiguity. A JSON merge patch is simpler: it is a partial document where a null value means delete and anything else means replace. jsondiffpatch's own delta format is neither, it is a compact internal encoding, and RFC 6902 output is available as one formatter among five.

Official sources

  1. benjamine/jsondiffpatch on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/benjamine-jsondiffpatch.svg)](https://hysenlabs.com/projects/benjamine-jsondiffpatch)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/benjamine-jsondiffpatch.svg)](https://hysenlabs.com/projects/benjamine-jsondiffpatch)

Was this useful?