JavaScript diff libraries

Updated Nov 2026

JavaScript diff libraries compare two versions of text or data and describe the changes between them. A text diff reports the characters or lines inserted and deleted, while an object diff reports the paths whose values changed. These libraries produce the changes shown in code review views, test failure messages, and collaborative editors.

Popularity

jsdiff has the most monthly downloads in this comparison, at 735.9M.

LibraryMonthly downloadsStarsLast releaseLicense
jsdiff
735.9M
9.2KApr 2026BSD-3-Clause
jest-diff
387.6M
45.5KSep 2026MIT
fast-diff
178.1M
715May 2023Apache-2.0
fast-json-patch
47.1M
2.0KMar 2022MIT
diff-match-patch
42.8M
269May 2020Apache-2.0
just-diff
35.4M
6.2KMar 2023MIT
microdiff
21.7M
3.9KAug 2026MIT
deep-object-diff
19.4M
1.1KNov 2022MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryText edit operationsObject field deltasApplies patches
jsdiffBuilt-inUnsupportedBuilt-in
jest-diffBuilt-inUnsupportedUnsupported
fast-diffBuilt-inUnsupportedUnsupported
fast-json-patchUnsupportedBuilt-inBuilt-in
diff-match-patchBuilt-inUnsupportedBuilt-in
just-diffUnsupportedBuilt-inVia plugin
microdiffUnsupportedBuilt-inUnsupported
deep-object-diffUnsupportedBuilt-inUnsupported
Built-inVia pluginNot supported

Libraries and code examples

Compares text tokens and creates or applies unified patches.

Downloads / mo
735.9M
Stars
9.2K
Last release
9.0.0
License
BSD-3-Clause

Strengths

  • Compares different text units. Choose character, word, or line comparisons.
  • Creates reversible unified patches. Generate a structured patch and reverse it to undo changes.

Limitations

  • Bounded comparisons can return undefined. Handle an aborted comparison when using timeout or maxEditLength.
  • Patch context must still match. Deleted lines and insertion boundaries must match even with fuzzFactor.

Quickstart

From node_example.js
$ npm install diff@9.0.0
const { diffChars } = require('diff');

console.log(diffChars('hello', 'hello world'));

jsdiff examples

From open-source projects on GitHub

Formats the differences between two values as text for people to review.

Downloads / mo
387.6M
Stars
45.5K
Last release
30.5.2
License
MIT

Strengths

  • Diffs any two values. Pass two values of any type to get a formatted difference string.
  • Customizes annotations and colors. Set annotations, colors, and context lines through DiffOptions.

Quickstart

From README.md
$ npm install jest-diff@30.5.2
const { diff } = require('jest-diff');

console.log(diff({ count: 1 }, { count: 2 }));

jest-diff examples

From open-source projects on GitHub
export function diffStrings__(a: string, b: string, diffOptions: DiffOptions): string {
  // jest-diff recommends using `diffLinesUnified` if string lengths are above 20,000 for performance
  if (a.length > 20_000 || b.length > 20_000) {
    return diffLinesUnified(a.split('\n'), b.split('\n'), diffOptions);
  }

  return diffStringsUnified(a, b, diffOptions);
}

Computes a text diff between two strings.

Downloads / mo
178.1M
Stars
715
Last release
1.3.0
License
Apache-2.0

Strengths

  • Returns edit tuples. Read each change as a delete, insert, or equal tuple.
  • Respects the cursor position. Pass a cursor position to place an ambiguous edit where the user typed.

Limitations

  • No match or patch functions. Patching and fuzzy matching stay in diff-match-patch.

Quickstart

From README.md
$ npm install fast-diff@1.3.0
const diff = require('fast-diff');

console.log(diff('hello', 'hello world'));

fast-diff examples

From open-source projects on GitHub

fast-json-patch

Generates, validates, and applies JSON Patch operations on object trees.

Downloads / mo
47.1M
Stars
2.0K
Last release
3.1.1
License
MIT

Strengths

  • Tracks changes to observed objects. Observe an object and generate the pending patch operations.
  • Validates patches against a document. Validate operation sequences against the target object tree.

Limitations

  • Patch application mutates by default. Disable mutateDocument or clone the document before applying changes.
  • Undefined values change meaning. Undefined object properties disappear; undefined array entries become null.

Quickstart

From README.md
$ npm install fast-json-patch@3.1.1
const { applyPatch } = require('fast-json-patch');

const document = { name: 'Ada' };
const patch = [{ op: 'replace', path: '/name', value: 'Grace' }];
const result = applyPatch(document, patch);
console.log(result.newDocument);

fast-json-patch examples

From open-source projects on GitHub

diff-match-patch

Diffs text, finds approximate matches, and applies text patches.

Downloads / mo
42.8M
Stars
269
Last release
1.0.5
License
Apache-2.0

Strengths

  • Cleans up readable text differences. Semantic cleanup groups coincidental matches into more understandable edits.
  • Reports individual patch outcomes. patch_apply returns changed text and success flags.

Limitations

  • Timed diffs can be nonoptimal. A timeout returns a valid difference without guaranteeing the smallest edit.
  • Large patches complicate success tracking. Internal splitting can make result flags outnumber the original patches.

Quickstart

From README.md
$ npm install diff-match-patch@1.0.5
import DiffMatchPatch from 'diff-match-patch';
const dmp = new DiffMatchPatch();

console.log(dmp.diff_main('hello', 'hello world'));

Returns the differences between two objects, with an option to format them as JSON Patch.

Downloads / mo
35.4M
Stars
6.2K
Last release
6.0.2
License
MIT

Strengths

  • Formats changes as JSON Patch. Pass jsonPatchPathConverter to get standard JSON Patch paths.

Quickstart

From README.md
$ npm install just-diff@6.0.2
const { diff } = require('just-diff');

console.log(diff({ count: 1 }, { count: 2 }));

just-diff examples

From open-source projects on GitHub

microdiff

Compares objects and arrays deeply with no dependencies.

Downloads / mo
21.7M
Stars
3.9K
Last release
1.6.0
License
MIT

Strengths

  • Returns typed change records. Read each change as CREATE, REMOVE, or CHANGE with its path.
  • Compares dates and regular expressions. Compare Date and RegExp values by their content.

Quickstart

From README.md
$ npm install microdiff@1.6.0
import diff from 'microdiff';

console.log(diff({ count: 1 }, { count: 2 }));

deep-object-diff

Compares two objects deeply, including nested arrays and objects, and returns the difference.

Downloads / mo
19.4M
Stars
1.1K
Last release
1.1.9
License
MIT

Strengths

  • Splits added, deleted, and updated values. Call detailedDiff to get added, deleted, and updated values separately.

Quickstart

From README.md
$ npm install deep-object-diff@1.1.9
const { diff } = require('deep-object-diff');

console.log(diff({ count: 1 }, { count: 2 }));

deep-object-diff examples

From open-source projects on GitHub

FAQ

jsdiff, published on npm as diff, compares text by characters, words, or lines and creates or applies unified patches.

fast-json-patch implements JSON Patch, a format that describes changes to a JSON document as a list of operations. It can also observe an object and generate the operations for its changes.

Microdiff, just-diff, and deep-object-diff compare two objects and report the changed paths. fast-json-patch returns the same changes as JSON Patch operations.

jsdiff compares text tokens and supports unified patches. fast-json-patch compares objects and generates operations from observations. diff-match-patch returns text differences and applies text patches.

applyPatch mutates by default; mutateDocument controls whether it clones first.

diffJson first sorts object properties, serializes them as pretty JSON, and compares the lines.

For coding agents

Found your diff library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official