.patch

What is a .patch file?

A patch file contains diffs that can be applied to source code — the classic way to distribute code changes.

Safe format
Type Code
By Unix tradition
MIME text/x-diff

Drop any file to identify it

No upload. No signup. No sending your file halfway across the internet.
We tell you what it is, right here in your browser.

What is it

A .patch file is functionally identical to a .diff file — it contains unified diff output showing what lines to add, remove, and change in source files. The distinction is conventional: .diff emphasises "these are the differences," while .patch emphasises "apply these changes."

Before Git, patches were how open-source software was developed. Developers generated patches with `diff -u`, emailed them to mailing lists, maintainers reviewed and applied them with `patch` or `git am`. The Linux kernel was developed this way for years. The workflow still exists — `git format-patch` generates email-ready patches.

Applying a patch: `git apply fix.patch` or `patch -p1 < fix.patch`. The `-p1` strips one directory level from paths — a convention from how patches are typically generated. Always review patches before applying, especially from untrusted sources, since they modify your source code.

Technical details
Full Name
Patch File
MIME Type
text/x-diff
Developer
Unix tradition
Magic Bytes
N/A
Safety
.patch is a known, safe format. Text file. Safe to read. Applying modifies source files — review before applying.
What opens it
VS Code
FREE Windows / Mac / Linux
Any text editor
FREE Windows / Mac / Linux
FAQ
Is .patch the same as .diff?
The file format is identical — both contain unified diff output. The extension choice is conventional: .diff for viewing differences, .patch for files intended to be applied to source code.
How do I create a patch?
`git diff > changes.patch` creates a patch from uncommitted changes. `git format-patch HEAD~3` creates patches for the last 3 commits, formatted for email distribution.
Related formats