# @thi.ng/diff

> Customizable diff implementations for arrays (sequential) & objects (associative), with or without linear edit logs

Latest version **5.1.129** (published 2026-08-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @thi.ng/diff
pnpm add @thi.ng/diff
yarn add @thi.ng/diff
bun add @thi.ng/diff
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.129 |
| Published | 2026-08-25 |
| First published | 2018-02-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Karsten Schmidt |
| Maintainers | thi.ng |
| Keywords | array, diff, editlog, object, typescript |

## Links

- npm: https://www.npmjs.com/package/@thi.ng/diff
- Repository: https://codeberg.org/thi.ng/umbrella
- Homepage: https://thi.ng/diff
- Funding: https://github.com/sponsors/postspectacular
- npm.io page: https://npm.io/package/@thi.ng/diff

## Dependencies (2)

- [@thi.ng/api](https://npm.io/package/@thi.ng/api.md) ^8.12.28
- [@thi.ng/equiv](https://npm.io/package/@thi.ng/equiv.md) ^2.1.117

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 5.1.129 (latest) — 2026-08-25
- 5.1.128 — 2026-07-02
- 5.1.127 — 2026-06-05
- 5.1.126 — 2026-05-23
- 5.1.125 — 2026-05-20
- 5.1.123 — 2026-05-11
- 5.1.122 — 2026-05-08
- 5.1.121 — 2026-04-26
- 5.1.120 — 2026-04-18
- 5.1.119 — 2026-04-02
- 5.1.118 — 2026-03-19
- 5.1.117 — 2026-03-07
- 5.1.116 — 2026-03-07
- 5.1.115 — 2026-02-07
- 5.1.114 — 2026-01-23
- … 216 more at https://npm.io/package/@thi.ng/diff/versions

## README

<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#changes-to-readme-files -->
# ![@thi.ng/diff](https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/banners/thing-diff.svg?e5b447c9)

[![npm version](https://img.shields.io/npm/v/@thi.ng/diff.svg)](https://www.npmjs.com/package/@thi.ng/diff)
![npm downloads](https://img.shields.io/npm/dm/@thi.ng/diff.svg)
[![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)

> [!NOTE]

> This is one of 217 standalone projects. LLM-free, human-made and
> cared for software, maintained as part of the
> [@thi.ng/umbrella](https://codeberg.org/thi.ng/umbrella/) ecosystem and
> anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring
> me](https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#donations).
> Thank you! ❤️

- [About](#about)
- [Status](#status)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [API](#api)
- [Authors](#authors)
- [License](#license)

## About

Customizable diff implementations for arrays (sequential) & objects (associative), with or without linear edit logs.

## Status

**STABLE** - used in production

[Search or submit any issues for this package](https://codeberg.org/thi.ng/umbrella/issues?q=%5Bdiff%5D)

## Installation

```bash
yarn add @thi.ng/diff
```

ESM import:

```ts
import * as diff from "@thi.ng/diff";
```

Browser ESM import:

```html
<script type="module" src="https://esm.run/@thi.ng/diff"></script>
```

[JSDelivr documentation](https://www.jsdelivr.com/)

For Node.js REPL:

```js
const diff = await import("@thi.ng/diff");
```

Package sizes (brotli'd, pre-treeshake): ESM: 1.06 KB

## Dependencies

- [@thi.ng/api](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/api)
- [@thi.ng/equiv](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/equiv)

Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)

## API

[Generated API docs](https://docs.thi.ng/umbrella/diff/)

```ts
import { diffArray } from "@thi.ng/diff";

// diff w/ default diff mode
diffArray([1, 2, 3], [1, 2, 4], "full");
// {
//     distance: 2,
//     adds: { 2: 4 },
//     dels: { 2: 3 },
//     const: { 0: 1, 1: 2 },
//     linear: [0, 0, 1,  0, 1, 2,  -1, 2, 3,  1, 2, 4]
// }
```

## Authors

- [Karsten Schmidt](https://thi.ng)

If this project contributes to an academic publication, please cite it as:

```bibtex
@misc{thing-diff,
  title = "@thi.ng/diff",
  author = "Karsten Schmidt",
  note = "https://thi.ng/diff",
  year = 2016
}
```

## License

&copy; 2016 - 2026 Karsten Schmidt // Apache License 2.0

---
_Source: https://npm.io/package/@thi.ng/diff · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
