Unified Diff Patch Applier
Apply a unified diff (git diff / diff -u output) to text in the browser — hunks matched at their line or the nearest offset, failures reported, reverse mode.
The patched text, a per-hunk report (applied, applied with offset, already applied, failed), counts, and the list of files in the patch.
Example: Lines a–e and a hunk "@@ -2,3 +2,3 @@ b / -c / +C / d" → line 3 becomes C; with an extra line on top it applies at offset +1 and says so; against unrelated text it fails, original returned.
Hunks,
applied like patch(1).
How a unified diff is read, how each hunk finds its place, and what happens when it does not.
Reading the diff
A unified diff has optional --- / +++ file headers and one or more hunks headed @@ -start,count +start,count @@, followed by context lines (space), removed lines (−) and added lines (+); “\ No newline at end of file” marks a missing final newline. Lines such as diff --git and index are ignored. Multi-file patches are split per file, and you choose which file to apply.
Placing a hunk
Each hunk’s context and removed lines must match the text exactly. The page tries the stated line first (shifted by what earlier hunks added or removed), then searches outward for the nearest place where the lines match and reports the offset — the same behaviour as patch and git apply without fuzz. “Ignore edges” compares lines with leading and trailing whitespace trimmed.
When it fails
A hunk that matches nowhere is skipped and listed; if its new lines are already present at the expected place it is reported as already applied. The output has every other hunk applied, like patch leaving a .rej file. Reverse swaps the added and removed sides to undo a patch. Line endings of the original (LF or CRLF) are kept. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- Unified diff format (GNU diffutils / git): @@ -old,count +new,count @@ hunks, context / minus / plus lines, no-newline marker; applied like patch(1): exact context, then the nearest offset
Last reviewed 21 September 2026. How results are checked: How we verify.