Turn Two Text Blocks into a Real .patch File
This diff patch generator lets you generate .patch from text directly, no git repository, no two files sitting on disk, just paste the original content and the modified version and get a real, applicable unified diff back. It's a fast way to generate patch file online output for a code review, a bug report, or sharing a proposed change with someone who doesn't have your repo checked out. Unlike a plain visual diff viewer, this is a genuine .patch file generator: the output is formatted to be consumed by real tooling, not just read by a human.
How to Use This Diff Patch Generator
Paste the original text into the first box and the modified version into the second, this text diff to patch conversion happens the moment you click Generate. Optionally set a filename (used in the diff header) and how many context lines of unchanged text to include around each change (0 to 10). Click Generate to create unified diff output, then copy the result or download it as a .patch file.
What a Unified Diff Actually Looks Like
A unified diff generator like this one produces output in a standard, well-documented format: a two-line header naming the original and modified file, then one or more @@ hunk headers, each followed by the actual changed lines.
| Line Prefix | Meaning |
|---|---|
| --- a/filename | The original file |
| +++ b/filename | The modified file |
| @@ -x,y +a,b @@ | A hunk header: original starts at line x for y lines, modified starts at line a for b lines |
| (space) | An unchanged context line |
| - | A line removed from the original |
| + | A line added in the modified version |
Applying the Generated Patch
Save the downloaded output as a .patch file, then apply it with git apply changes.patch inside a git repository, or patch -p1 < changes.patch for a plain directory that isn't a git repo. This is a genuine git apply patch generator, its output was tested directly against the standard diff -u command-line tool and confirmed to match line-for-line. One honest limitation: the underlying comparison is a line-level LCS diff, not a word-level or character-level one, so changing even a single character in a long line shows that entire line as removed and re-added rather than highlighting just the changed character, the same behavior real command-line diff tools have by default.