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.
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
Replace the two examples: paste or type. The differences update as you type.
Stays in your browserYour text is compared on this device and never uploaded. It is not saved either: reload the page and it is gone.
Differences
1 line changed, 1 added, 1 removed · 7 words added, 9 words removed
Counts
- Lines changed
- 1
- Lines added
- 1
- Lines removed
- 1
- Words added
- 7
- Words removed
- 9
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
| 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. |
The example as a unified diff
| 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 to compare two texts
- Paste the original. Put the older or reference version in the “Original” box, replacing the example.
- Paste the changed text. Put the newer version in the “Changed” box. The differences appear as you type.
- Choose what counts as a difference. Tick “Ignore case”, “Ignore whitespace changes” or “Ignore blank lines” to hide changes you do not care about.
- 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.
- Copy the diff. Press “Copy as unified diff” to paste a standard patch into a review, a ticket or a terminal.
Frequently asked questions
- 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.
- 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.
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.
Sources
More free tools
- Remove Duplicate LinesRemove duplicate lines from a list, keep the first or last copy, and sort A to Z, naturally or at random. Works in any language and stays in your browser.
- Word CounterCount words, characters, sentences and reading time, and check your text against X, LinkedIn, Instagram, SMS and meta description limits.
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE. Stays in your browser.
- JSON Formatter & ValidatorValidate JSON with the exact line and column of any error, then pretty-print, minify or sort keys. Big numbers keep every digit. Runs in your browser.
- Regex TesterTest JavaScript regular expressions: highlighted matches, capture groups, replacements with $1 or $<name>. Stops runaway patterns. Runs in your browser.
- Lorem Ipsum GeneratorGenerate lorem ipsum by paragraphs, sentences, words or an exact character count, as plain text, HTML or Markdown. Built from the classic Latin passage.