Compare Two Texts
Line-by-line differences, computed in your browser.
Everything is processed in this tab. Nothing you paste is sent anywhere.
Every tool runs entirely in your browser. Your files are never uploaded to a server.
A diff finds the longest sequence of lines the two versions share, then reports everything else as added or removed. Lines prefixed with a minus are only in the first version, a plus only in the second.
How to use Text Diff
- Paste the original. The first version goes in the top box.
- Paste the changed version. The second goes in the box below it.
- Read the differences. Minus lines were removed, plus lines added, with counts beside them.
About comparing two texts
Comparing two versions of a text is one of those tasks that is trivially easy to describe and surprisingly involved to do well. The naive approach — walk both versions together and report the first mismatch — falls apart as soon as a line is inserted, because everything after it appears changed when nothing was. The standard solution is to find the longest common subsequence: the largest set of lines appearing in both versions in the same order. Whatever falls outside it is reported as removed from the first or added to the second, which produces the smallest sensible description of what happened rather than merely a correct one. This works on whole lines, which is the same granularity version control uses and is a deliberate trade. Changing a single word reports the line as removed and a replacement added, rather than highlighting the word. That is less precise but far easier to scan, and it avoids the noisy output that character-level comparison produces on ordinary prose. The whitespace option matters more than it sounds. Re-indented code, text copied out of a word processor and files that have travelled between operating systems routinely differ in ways that are invisible on screen, and comparing without trimming reports them all. Everything here runs in the browser, which is the practical point: contracts, credentials and unreleased source can be compared without being sent anywhere. Two versions go in two separate boxes, which is worth mentioning only because the obvious alternative is worse: putting both into one box with a marker line between them fails the moment the text itself contains that marker, and a line of three dashes is a YAML front-matter delimiter, a Markdown horizontal rule and an email signature separator. Splitting on it silently compared the wrong halves and discarded whatever came after the second one. Very large inputs are handled by stripping identical beginnings and endings before any alignment is attempted, which reduces the common case — a small edit inside a large document — to almost no work at all. Beyond a memory budget the comparison falls back to matching line against line and labels itself approximate, rather than allocating a table proportional to the product of the two lengths and taking the tab down with it.
Frequently asked questions
Is my text uploaded anywhere?
Why does a small edit show as a whole line changed?
What does ignoring whitespace do?
How does the comparison decide what changed?
Is there a size limit?
Last updated