# Unified Diff & Patch Generator

> Produce a unified diff between two texts that git apply and patch can consume.

A unified diff records the changes between two versions of a file as hunks of context, removed and added lines. This generator computes the longest common subsequence, groups changes into hunks with the context you choose, and emits a patch that both git apply and the patch command accept.

**URL:** https://convertto.tech/t/diff-to-patch
**Category:** Developer Tools (https://convertto.tech/c/developer-tools)
**Privacy:** Runs entirely in the browser; no upload
**Cost:** Free, no sign-up
**Last updated:** 2026-08-01

## Key facts

- **Privacy:** Runs entirely in your browser — nothing is uploaded
- **Cost:** Free, unlimited, no sign-up

## How to use

1. Enter or paste your original.
2. Enter or paste your changed.
3. Enter or paste your file name.
4. Set the context lines.
5. The result appears immediately — copy or download it.

## FAQ

### What is the number in @@ -1,4 +1,5 @@?

The hunk header: the affected lines start at line 1 and span 4 lines in the original, and start at line 1 and span 5 in the new version. It is how patch finds the right place even if surrounding content has shifted.

## Related tools

- [Compare Two PDFs](https://convertto.tech/t/compare-pdfs): See two versions side by side, overlaid or wiped between — with every changed area outlined.
- [Text Diff Checker](https://convertto.tech/t/diff-checker): Compare two texts and highlight exactly what was added and removed.
- [Git Command Builder](https://convertto.tech/t/git-command-builder): Build the exact git command for fifteen common tasks, with explanations and safety notes.
- [.gitignore Generator](https://convertto.tech/t/gitignore-generator): Build a .gitignore file for your stack, with the entries people usually forget.
- [JSON Diff](https://convertto.tech/t/json-diff): Compare two JSON documents and see exactly which keys were added, removed or changed.
- [Semantic Version Checker](https://convertto.tech/t/semver-checker): Test versions against a range, sort by precedence, or compare two releases.
- [Line Endings Converter](https://convertto.tech/t/line-endings-converter): Convert between CRLF, LF and CR, and strip trailing whitespace.
- [Weighted Decision Matrix](https://convertto.tech/t/decision-matrix): Score options against weighted criteria and see which choice actually wins.
