Diff Patch Applier
Apply unified diff patches to text, reverse-apply patches, review individual hunks, and generate diffs between two texts.
About This Tool
The Diff Patch Applier is a free, browser-based tool that lets you apply unified diff patches to text instantly. Unified diffs are the standard format used by git diff, diff -u, and most version control systems. Whether you received a .patch file from a colleague, copied a diff from a pull request, or need to reconstruct a modified file from an original and a patch, this tool handles it all without leaving your browser.
The tool operates in two modes. In Apply Patch mode, you paste your original text in the left panel and a unified diff in the right panel, then click Apply. The engine parses the patch, applies each hunk to the original text, and displays the patched result below. You can also enable Reverse Apply to unapply a patch — useful when you need to revert a change or recover the original file from a patched version and the diff. Each hunk is shown individually with accept/reject toggles, so you can cherry-pick which changes to include.
In Generate Diff mode, paste two versions of a text and the tool produces a clean unified diff output that you can copy and share. The diff generator uses an LCS (Longest Common Subsequence) algorithm to compute minimal changes with configurable context lines, just like the output of diff -u.
If you need to visually compare two texts side by side, try the Diff Viewer. For resolving Git merge conflicts with three-way comparison, check out the Git Conflict Resolver. To transform text casing while working with patches, the Text Case Converter is a handy companion.
All processing runs entirely in your browser. No text, patch, or diff data ever leaves your machine — there are no server requests, no logging, and no third-party services involved. This makes the tool safe to use with proprietary code, internal documentation, or any sensitive content.
How to Use
- Select a mode: Apply Patch to apply a unified diff, or Generate Diff to create one from two texts.
- In Apply Patch mode, paste your Original Text in the left panel.
- Paste the Unified Diff / Patch content in the right panel (lines starting with
+,-, and@@hunk headers). - Optionally enable Reverse (unapply) to reverse the direction of the patch.
- Click Apply Patch (or press Ctrl+Enter) to produce the patched result.
- Review individual hunks below the output — click a hunk to accept or reject it. The result updates automatically.
- Click Copy or press Ctrl+Shift+C to copy the result to your clipboard.
Popular Diff Patch Applier Examples
FAQ
What is a unified diff format?
A unified diff is a standard text format for representing changes between two files. It uses lines starting with '+' for additions, '-' for removals, and ' ' (space) for unchanged context lines. Hunk headers like '@@ -1,5 +1,7 @@' indicate the line ranges. This format is produced by 'git diff', 'diff -u', and most version control tools.
Can I apply patches from git diff output?
Yes. The tool accepts standard unified diff output produced by 'git diff', 'git format-patch', 'svn diff', and the Unix 'diff -u' command. Simply paste the diff content including the '---' and '+++' file headers and the '@@ ... @@' hunk headers.
What does reverse apply do?
Reverse apply (unapply) swaps the meaning of '+' and '-' lines in the patch. This effectively undoes a patch: additions become removals and vice versa. It is useful when you have a patched file and want to recover the original, or when you need to revert a specific change.
What happens if a hunk fails to apply?
When a hunk's context lines don't match the original text, the tool reports which hunks failed. You can review each hunk individually and toggle accept/reject. Successfully applied hunks are included in the result while failed hunks are skipped. The tool also tries fuzzy matching within a few lines of the expected position.
Can I selectively apply hunks?
Yes. After applying a patch, each hunk is displayed with a checkbox. Click a hunk or its checkbox to toggle between accepted and rejected. The result output updates automatically to reflect only the accepted hunks, similar to 'git add -p' interactive staging.
Is my data safe?
Yes. All patch parsing, diff generation, and text processing runs entirely in your browser using JavaScript. No data is sent to any server. You can verify this by checking the Network tab in your browser's developer tools while using the tool.
Can I generate a diff between two texts?
Yes. Switch to 'Generate Diff' mode, paste the original text in the left panel and the modified text in the right panel, then click Generate Diff. The tool computes the differences using an LCS algorithm and outputs a clean unified diff that you can copy and use with patch tools or version control systems.
Related Tools
Diff Viewer
Compare two texts side by side with line-by-line and character-level diff highlighting.
Git Conflict Resolver
Resolve git merge conflicts visually. Paste conflict markers, compare sides, and choose or edit the resolution.
Word & Character Counter
Count words, characters, sentences, paragraphs, and estimate reading time with keyword frequency analysis.
String Escape/Unescape
Escape and unescape strings for JSON, JavaScript, HTML, URL, SQL, and CSV formats.
Text Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, and other naming conventions.
Text Diff Merger
Three-way merge tool. Resolve conflicts between Base, Mine, and Theirs versions of text.