# Text Compare

Paste two versions of a text and see exactly what changed: lines that were added or removed, and inside a changed line the individual words. The example below comes out as 1 line changed, 1 added, 1 removed · 7 words added, 9 words removed. You can ignore upper and lower case, ignore extra spaces and tabs, or skip blank lines, and copy the result as a standard unified diff (the ---, +++ and @@ format used by git and patch). Both texts are compared in your browser and never leave it.

Canonical page: https://ponderloop.com/tools/text-compare/
Updated: 2026-10-03

## How to use

How to compare two texts

1. **Paste the original**: Put the older or reference version in the “Original” box, replacing the example.
2. **Paste the changed text**: Put the newer version in the “Changed” box. The differences appear as you type.
3. **Choose what counts as a difference**: Tick “Ignore case”, “Ignore whitespace changes” or “Ignore blank lines” to hide changes you do not care about.
4. **Read the result**: Removed lines are marked − and added lines +. In a changed line, the words that differ are struck through or underlined. Choose side by side or unified layout.
5. **Copy the diff**: Press “Copy as unified diff” to paste a standard patch into a review, a ticket or a terminal.

## Reference tables and worked examples

### How to read the result

| What you see | Meaning |
| --- | --- |
| − (red) | Only in the original text: the line, or the words, that were removed. |
| + (green) | Only in the changed text: the line, or the words, that were added. |
| Underlined or struck-through words | Inside a changed line, the words that differ. Removed words are struck through, added words are underlined. |
| N unchanged lines not shown | A long run of identical lines folded away; tick “Show all unchanged lines” to see them. |

### What each option does

The same pair of texts compared with the option off and on.

| Option | Original vs changed | Option off | Option on | Effect |
| --- | --- | --- | --- | --- |
| Ignore case | “Hello World / second” vs “hello world / second” | 1 line differs | No differences | “Hello” and “hello” count as the same. |
| Ignore whitespace changes | “a b / c” vs “a b / c” | 2 lines differ | No differences | Runs of spaces and tabs count as one space; spaces at the ends of a line are ignored. |
| Ignore blank lines | “one / (blank) / two” vs “one / two / (blank) / (blank)” | 2 lines differ | No differences | Blank lines are dropped from both texts first, so line numbers count only the lines that remain. |

### How common edits are reported

Each pair compared with the same functions as the tool, with the default options unless the row says otherwise.

| Edit | Original vs changed | Result |
| --- | --- | --- |
| One word replaced | “The meeting is on Monday.” vs “The meeting is on Friday.” | 1 line changed, 0 added, 0 removed · 1 word added, 1 word removed |
| A line added | “apples / bananas” vs “apples / cherries / bananas” | 0 lines changed, 1 added, 0 removed · 1 word added, 0 words removed |
| A line removed | “apples / cherries / bananas” vs “apples / bananas” | 0 lines changed, 0 added, 1 removed · 0 words added, 1 word removed |
| Two lines swapped | “one / two / three” vs “one / three / two” | 0 lines changed, 1 added, 1 removed · 1 word added, 1 word removed |
| Capital letter only | “Paris is in France.” vs “paris is in France.” | 1 line changed, 0 added, 0 removed · 1 word added, 1 word removed |
| Capital letter only, ignore case on | “Paris is in France.” vs “paris is in France.” | No differences |
| Extra space inside a line | “total = a + b” vs “total = a + b” | 1 line changed, 0 added, 0 removed · 0 words added, 0 words removed |
| Extra space inside a line, ignore whitespace on | “total = a + b” vs “total = a + b” | No differences |
| Windows against Unix line endings | “a / b / c” vs “a / b / c” | No differences |
| Identical texts | “same / text” vs “same / text” | No differences |

### The example as a unified diff

This is what “Copy as unified diff” puts on the clipboard for the example texts.

| Line | Meaning |
| --- | --- |
| --- original | Name of the original |
| +++ changed | Name of the changed text |
| @@ -1,4 +1,4 @@ | Hunk header: starting line and number of lines in the original, then in the changed text |
| -The quick brown fox | Only in the original |
| +The quick red fox | Only in the changed text |
| jumps over the lazy dog. | Unchanged context |
| -Pack my box with five dozen liquor jugs. | Only in the original |
| Sphinx of black quartz, judge my vow. | Unchanged context |
| +How vexingly quick daft zebras jump! | Only in the changed text |

## How it works

Each text is split into lines on LF, CRLF or CR. Lines are compared by a key: the line itself, with runs of spaces and tabs collapsed and the ends trimmed if “Ignore whitespace changes” is on, and lower-cased if “Ignore case” is on; with “Ignore blank lines” on, blank lines are removed first. The identical beginning and end of the two texts are set aside, then Myers’ O(ND) algorithm finds a shortest list of line additions and removals (Myers, “An O(ND) Difference Algorithm and Its Variations”, 1986). Its cost grows with the number of changes, so it stops after 1,000 changes in a region; the rest of that region is then split at lines that occur exactly once in both texts (the patience diff idea), kept in their original order by a longest increasing subsequence, and anything still unmatched is shown as removed followed by added. Inside each run of removed and added lines, the first removed line is paired with the first added line, and so on; a pair is compared again word by word (runs of letters and digits, runs of spaces, single punctuation marks) with the same algorithm. “Lines changed” counts such pairs, “lines added” and “lines removed” count the lines left unpaired, and “words added” and “words removed” count the words that differ inside pairs plus every word on a purely added or removed line. Unchanged lines are folded to 3 lines of context around each change unless you ask to see them all. The unified diff uses the same line comparison, three lines of context, and merges hunks whose context would overlap.

## FAQ

### How do I find the difference between two texts?

Paste one text in each box. The page lines the two up, marks every line that is only in one of them, and highlights the words that changed inside lines that differ. Nothing needs to be submitted: the comparison updates as you type.

### Is my text uploaded or saved?

No. The comparison runs in your browser and the text is never uploaded, stored or logged. It is gone when you close or reload the page. The only thing the site records, if you allow analytics, is that a button was used, never any of the text.

### What is a unified diff?

The plain-text format that diff -u, git diff and patch use. It starts with “--- original” and “+++ changed”, then one or more hunks. Each hunk begins with “@@ -a,b +c,d @@” (b lines from line a of the original, d lines from line c of the changed text), followed by lines that start with a space (unchanged), “-” (removed) or “+” (added), with three lines of unchanged context around each change.

### How are changed words highlighted?

A line that was edited is paired with its replacement and the two are compared word by word, so a single new word is highlighted instead of the whole line. When one side has more changed lines than the other, the extra lines show as plain additions or removals. A “word” is a run of letters, digits and underscores; punctuation changes are highlighted too but not counted as words.

### What do “ignore case” and “ignore whitespace” do?

“Ignore case” compares lines and words without regard to capital letters. “Ignore whitespace changes” treats any run of spaces and tabs as a single space and ignores spaces at the start and end of a line, so re-indented or re-wrapped spacing is not a difference. Lines that match only because of these options are shown as unchanged, exactly as you typed them.

### Why do the line numbers skip when I ignore blank lines?

With “Ignore blank lines” the blank lines are removed from both texts before comparing, so the numbers count only the lines that remain, and the copied unified diff is numbered the same way. Leave the option off if you need a diff that applies to the original file with patch.

### Can it compare very long texts?

Yes. Texts of 5,000 lines compare in a fraction of a second. The comparison finds the shortest list of changes, up to 1,000 changes at a time; if two large texts differ even more than that, the page falls back to a coarser comparison anchored on lines that appear exactly once in both, and tells you the result is approximate. For very large pastes the result updates a moment after you stop typing, and at most 2,000 rows are drawn, while the counts and the copied diff always cover everything.

### Does it work with Hebrew, Arabic, Chinese or accented text?

Yes. Lines and words are compared as Unicode text, and each box takes its reading direction from the first letter you type, so right-to-left text such as Hebrew and Arabic reads correctly. Chinese and Japanese, which have no spaces, are compared line by line with the changed stretch highlighted.

### How do I compare two files, two documents or two pieces of code?

Open each one, copy its text, and paste it into the Original and Changed boxes. The page compares text, not files, so a Word document, a PDF or a spreadsheet must be copied out as plain text first. For code, “Copy as unified diff” gives the same format as git diff, which a review tool or patch can read.

### Does it show moved lines?

Not as moves. A line that moves is reported as removed from its old place and added in its new one. Swapping “two” and “three” in a three-line list comes out as 0 lines changed, 1 added, 1 removed · 1 word added, 1 word removed, because the shortest set of line edits is one removal and one addition.

### Is a difference in capital letters or spaces a difference?

By default, yes. “Paris is in France.” against “paris is in France.” is 1 line changed, 0 added, 0 removed · 1 word added, 1 word removed; with Ignore case on it is no differences. Spacing works the same way: extra spaces inside a line count as a change until Ignore whitespace changes is on.

### How is one changed word counted?

A line edited in place counts as one changed line, and only the words that differ are counted. Changing “Monday” to “Friday” in one sentence is 1 line changed, 0 added, 0 removed · 1 word added, 1 word removed.

### Is a Windows line ending a difference?

No. The same three lines with CRLF endings against LF endings come out as no differences, because every kind of line break is treated alike before the lines are compared.

### What about line endings and the final newline?

Windows (CRLF), Mac (CR) and Unix (LF) line endings are treated alike, and a final line break at the end of a text is ignored, so those are never reported as differences. The unified diff always uses plain line feeds and has no “No newline at end of file” markers.

## Sources

- [Eugene W. Myers: An O(ND) Difference Algorithm and Its Variations (Algorithmica, 1986)](https://doi.org/10.1007/BF01840446)
- [GNU Diffutils manual: Unified Format](https://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html)
- [Git documentation: git-diff, generating patch text](https://git-scm.com/docs/git-diff)
- [Unicode Standard Annex #29: Text Segmentation (words)](https://unicode.org/reports/tr29/)

---

Cite as: Text Compare, ponderloop, https://ponderloop.com/tools/text-compare/, updated 2026-10-03
