Patch Applier

Apply a unified-diff .patch to your source text right in the browser.

Ad placeholder (leaderboard)

A unified-diff patch describes a change as a set of hunks, each one a window of context lines plus the lines to remove (-) and add (+). The Patch Applier takes such a patch and your original text and produces the patched output in your browser — useful for applying a shared diff when you do not have a checkout to run git apply against.

How it works

  1. The patch is parsed into hunks: each @@ -a,b +c,d @@ header starts a new hunk, and the following , -, + lines are collected.
  2. For each hunk, the tool builds the expected old block (context + removed lines) and the new block (context + added lines).
  3. It looks for the old block at the header’s line number; if that does not match exactly, it searches nearby lines for the same block (fuzzy location), so a small drift in the file still applies.
  4. On a match it splices in the new block; on no match the hunk is rejected and the original lines are kept.

Example

Applying this hunk:

@@ -1,3 +1,3 @@
 .btn {
-  color: red;
+  color: blue;
 }

to a source whose first lines are .btn { / color: red; / } yields the same block with blue instead of red.

Notes

Hunks are applied independently, so a partly-stale patch still lands the hunks that match while clearly flagging those that do not. Line endings are normalised to \n during matching. Everything runs locally — your source and patch never leave the browser.

Ad placeholder (rectangle)