How a text compare tool finds differences
A text compare tool finds the longest run of lines the two texts share, in the same order, and calls everything else a difference. Lines that appear only in the original are removed, lines that appear only in the second text are added, and the rest are unchanged. This tool then looks inside each pair of neighboring removed and added lines and repeats the process on words, which is how a single changed number gets highlighted instead of the whole line.
The method is Eugene Myers' 1986 algorithm, described in his paper on the shortest edit script between two sequences. It searches for the fewest insertions and deletions that turn one text into the other, and it is fast when the texts are alike, because the work grows with the number of differences and not with the size of the texts. Git's default diff algorithm is Myers too, so results here should agree with what a developer sees on the command line.
Here is that exact example, run through this page's code. One line differs by a single word, so it is marked "changed" with that word highlighted, and one line has no counterpart.
| Original line | New line | Result | Text |
|---|---|---|---|
| 1 | 1 | Unchanged | Meeting agenda |
| 2 | 2 | Unchanged | - Welcome |
| 3 | 3 | Changed | - Review of Q4 budget |
| 4 | 4 | Unchanged | - Hiring plan |
| 5 | Added | - Office move | |
| 5 | 6 | Unchanged | - Questions |
Source: Summary: 1 added, 0 removed, 1 changed, 4 unchanged.
What do the diff terms mean?
Programmers invented most of the vocabulary, and it has spread to lawyers, editors and anyone who tracks versions of a document.
| Term | Meaning |
|---|---|
| Diff | The list of differences between two texts, or the tool that produces it |
| Added / removed | A line present only in the new text / only in the original |
| Changed | In this tool, a removed line and an added line next to each other, paired so their words can be compared |
| Hunk | A group of nearby changes shown together with a few unchanged lines around them |
| Context | The unchanged lines around a hunk, usually three, that show where the change sits |
| Unified diff | A plain-text format with + and - at the start of lines, used by patch tools and code review |
| Patch | A diff saved so it can be applied to the original to produce the new text |
How do you read a unified diff?
Copy result puts a unified diff on your clipboard, with one line of context around each change. The format is defined in the POSIX specification of diff. For the example above it looks like this:
@@ -2,4 +2,5 @@ - Welcome -- Review of Q3 budget +- Review of Q4 budget - Hiring plan +- Office move - Questions
| Starts with | Meaning |
|---|---|
| @@ -2,4 +2,5 @@ | Hunk header: starts at line 2 and spans 4 lines in the original, starts at line 2 and spans 5 in the new text |
| - | Line only in the original |
| + | Line only in the new text |
| (space) | Unchanged context line |
What do ignore case and ignore whitespace do?
Both options change what counts as "the same" before the comparison runs. The text shown is always your original text; only the matching is relaxed.
| Option | These match | These still differ |
|---|---|---|
| Ignore case | Hello World and hello world | Hello World and Hello Word |
| Ignore whitespace | "a b" and "a b"; leading or trailing spaces; tab versus space | "a b" and "ab" |
| Neither | Only lines that match character for character | A stray trailing space counts as a change |
Source: Line endings (Windows CRLF versus Unix LF) never count as a difference in this tool.
What a diff cannot see
A diff compares order, not meaning. If you move a paragraph from the top of a page to the bottom, the tool shows it as removed in one place and added in another, because no ordered sequence of lines can contain it in both positions. Likewise, a paragraph that was re-wrapped to a different line width looks entirely changed, since the lines it was made of no longer exist.
Put one sentence on each line before comparing. A one-word edit then lights up one line, and a re-wrap stops mattering. Most editors can do this with find and replace on ". ". To see how long each draft is first, paste it into our word counter, and keep drafts you want to compare in our online notepad.
Common mistakes
- Reading a fully red and green result as a rewrite. It is often a line-ending, indentation or re-wrap change. Turn on Ignore whitespace before concluding anything.
- Swapped sides. Red is always the left box. If the result looks backwards, press Swap.
- Curly quotes and look-alike characters. A straight quote and a curly quote are different characters, so lines that look identical still show a changed word.
- Hidden trailing spaces. A line that ends in a space is not the same line. The word highlight cannot show a space, so check the whitespace option when two lines seem equal.
- Treating a diff as a legal verdict. It shows that texts differ. It does not say which version is right or whether a change matters.
Common questions
Is the text I paste uploaded?
No. The comparison runs in your browser and the page does not send the text anywhere or save it to local storage. Closing the tab discards it. The site does count page views.
How large a text can I compare?
A few thousand lines compare instantly. Very different texts of tens of thousands of lines can take longer, and beyond that point the tool stops searching for a minimal answer and marks the remaining lines as replaced.
What is the difference between line and word comparison?
Lines are compared first to find what was added, removed or kept. Words are compared afterwards, only inside lines that changed, to show which words moved.
Can it compare two files?
Paste the contents of each into the boxes. The tool works on text, so it suits code, notes, contracts in text form, and configuration files, but not Word or PDF files directly. To compare two JSON documents, run each through our JSON formatter first so both use the same indentation and line breaks.
What does the match percentage in the gauge mean?
It is the share of characters that match on both sides, counting the unchanged words inside changed lines. 100 appears only when nothing differs. The five band names (light edit, revised, heavily reworked and so on) are this site's own rough guide, not a standard, and a moved paragraph lowers the score because a diff reads it as a removal plus an addition.
Why is a moved block shown twice?
As a removal where it was and an addition where it landed. See "What a diff cannot see" above.
Sources
- Eugene W. Myers, "An O(ND) Difference Algorithm and Its Variations" (Algorithmica, 1986)
- The Open Group: diff, POSIX specification
- Git documentation: git-diff, diff algorithms
- MDN Web Docs: Clipboard.writeText()
Last reviewed November 9, 2026.