Skip to content

Unified Diff Generator

Compare two texts and get a unified diff in the format of diff -u and git diff. Paste the original and the changed text, name the files and choose how many lines of context to keep. The patch can be applied with patch, git apply or the Patch Apply tool.

Reset

Frequently asked questions

What does the output look like?

It starts with --- and +++ lines naming the original and changed file, followed by hunks that begin with @@ -start,count +start,count @@. Lines starting with a space are unchanged, - lines are removed and + lines are added.

What does the context setting change?

It sets how many unchanged lines are shown around each change, from 0 to 20. Three lines is the default of diff -u and git diff, and enough for patch tools to find the right place.

What does ignore whitespace do?

Lines that differ only in spaces or tabs are treated as equal, so changes in indentation or trailing spaces do not appear as changes.

What does No newline at end of file mean?

This marker, also printed by diff and git, says that the last line of a text has no line break after it. It keeps the patch exact when one version ends with a newline and the other does not.

Can I apply the result with git?

Yes. Save it as a .patch or .diff file and run git apply or patch -p0. Name the files as they are named in your repository, for example a/src/app.js and b/src/app.js with patch -p1.

Why do I get an error for very different texts?

Computing a diff between two long texts that share almost nothing takes a lot of work. If the comparison takes longer than three seconds it is stopped, and you can compare smaller parts instead.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.