Diff Patch Generator & Apply Online

在浏览器中比较一个文本文件的两个版本,生成 unified diff,或应用单文件补丁。

ORIGINAL
MODIFIED

When to use Diff / Patch Generator

Generate a unified diff for one text file and preview how a matching patch changes the original text.

How to use Diff / Patch Generator

In Generate, enter both versions and a filename, then generate the patch. In Apply, enter the original text and patch and inspect the result or mismatch error.

Worked example

Example — verified tool behavior
a followed by a newline → b followed by a newline: @@ -1,1 +1,1 @@ followed by -a and +b

How the tool handles input

The tool uses a/ and b/ filename headers and includes up to three context lines on each side of a change. When the final line lacks a newline, the patch records that explicitly. Apply checks each hunk before returning the result.

Limitations

Apply a unified diff for one text file at a time. The hunk line numbers and context must match the supplied original text. Binary patches, renames and multi-file patches are outside this tool’s scope.

Frequently asked questions

Can this patch files on disk?

No. It produces or applies text within the tool; it does not edit repository files.

What are the main limitations?

Apply a unified diff for one text file at a time. The hunk line numbers and context must match the supplied original text. Binary patches, renames and multi-file patches are outside this tool’s scope.