# parse-diff

> Unified diff parser

Latest version **0.12.0** (published 2026-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install parse-diff
pnpm add parse-diff
yarn add parse-diff
bun add parse-diff
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2026-04-17 |
| First published | 2014-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 33.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sergey Todyshev |
| Maintainers | sergeyt |
| Keywords | diff, unidiff, parser |

## Links

- npm: https://www.npmjs.com/package/parse-diff
- Repository: https://github.com/sergeyt/parse-diff
- Homepage: https://github.com/sergeyt/parse-diff#readme
- Issues: https://github.com/sergeyt/parse-diff/issues
- npm.io page: https://npm.io/package/parse-diff

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.12.0 (latest) — 2026-04-17
- 0.11.1 — 2023-03-20
- 0.11.0 — 2023-01-19
- 0.10.0 — 2022-11-16
- 0.9.0 — 2021-12-16
- 0.8.1 — 2021-03-13
- 0.8.0 — 2021-03-12
- 0.7.1 — 2020-09-11
- 0.7.0 — 2020-02-13
- 0.6.0 — 2019-08-29
- 0.5.1 — 2018-09-29
- 0.5.0 — 2018-09-29
- 0.4.2 — 2018-03-05
- 0.4.1 — 2018-01-31
- 0.4.0 — 2016-10-05
- … 19 more at https://npm.io/package/parse-diff/versions

## README

[![Build Status](https://github.com/sergeyt/parse-diff/actions/workflows/ci.yml/badge.svg)](https://github.com/sergeyt/parse-diff/actions/workflows/ci.yml)
[![Total downloads](https://img.shields.io/npm/dt/parse-diff.svg)](https://www.npmjs.com/package/parse-diff)

[![NPM](https://nodei.co/npm/parse-diff.png?downloads=true&stars=true)](https://nodei.co/npm/parse-diff/)

# parse-diff

Simple unified diff parser for JavaScript

## JavaScript Usage Example

```javascript
var parse = require('parse-diff');
var diff = ''; // input diff string
var files = parse(diff);
console.log(files.length); // number of patched files
files.forEach(function(file) {
	console.log(file.chunks.length); // number of hunks
	console.log(file.chunks[0].changes.length) // hunk added/deleted/context lines
	// each item in changes is a string
	console.log(file.deletions); // number of deletions in the patch
	console.log(file.additions); // number of additions in the patch
});
```

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