Works on this device
Text Difference Checker
Paste two texts, or open two files, to see what is different between them. The tool lists the lines that were removed and added, marks the words that changed, and gives a unified diff that you can copy or download. Both texts are compared in this browser and are not uploaded.
Your two texts
Check these values
Your values are worked out in this browser. They are not sent to a server.
The differences will show here
Put a text in each box, or choose Try an example.
Differences
How it was worked out
How to compare two texts
- Put the first text (for example the old version) in the first box and the second text in the second box. You can type, paste, or choose Or open the first file from your device. Text files, Word .docx files and PDF files with real text can be opened.
- Choose how to compare: line by line as one list, line by line side by side, or word by word.
- Set the options if you need them: treat capital and small letters as the same, ignore white space, or leave out empty lines.
- Read the result. It updates as you type. If nothing differs, the result says No differences.
- Choose Copy text or Download file to keep the unified diff, or Download CSV to keep the whole table.
How to read the result
- − only in first: the line is in the first text and not in the second. It was removed.
- + only in second: the line is in the second text and not in the first. It was added.
- = same: the line is in both texts.
- ≠ changed (side by side view): a removed line and the added line that took its place, in one row.
- Inside a changed line,
[-text-]marks the part that is only in the first text and{+text+}marks the part that is only in the second text. - Every difference is named with a word and a symbol. Colour is not needed to read the result.
- A row such as
⋯ 12 lines that are the same are not shownstands for lines that were left out because they are far from any change.
The options
- Treat capital and small letters as the same:
Helloandhellocount as the same. - White space: compare it exactly; ignore it at the end of a line; ignore how much there is (one space and three spaces count as the same, and spaces at both ends of a line are ignored); or ignore all of it.
- Leave out empty lines: lines with no text are not compared and not listed. The result says how many were left out.
- Lines to list: changed lines with some lines around them (you set how many), changed lines only, or all lines.
- A line that is the same under your options is shown as it is written in the first text.
The method
The tool splits each text into lines. It then finds the largest set of lines that are in both texts in the same order. This is called a longest common subsequence. All other lines are listed as removed or added. The search uses the difference algorithm that Eugene Myers described in 1986, which the diff program also uses.
Share of lines that match = 2 × lines that are the same ÷ (lines in the first text + lines in the second text).
The word by word option does the same with words and punctuation marks, and ignores spaces and line breaks. It is good for prose that was edited or wrapped in a new way.
The unified diff
The text box holds the differences in the unified diff format, which the diff, patch and git programs use. A line that starts with - is only in the first text, a line that starts with + is only in the second, and a line that starts with a space is in both. Each group starts with a line such as @@ -1,5 +1,5 @@: the group covers 5 lines from line 1 of the first text and 5 lines from line 1 of the second text.
A line break at the very end of a text is not recorded in the diff. If you use options that ignore differences, use the diff for reading only.
Worked example
First text: The quick brown fox, jumps over the lazy dog., This line is removed., Same line here., Last line (5 lines). Second text: The quick red fox, jumps over the lazy dog., Same line here., A new line is added., Last line (5 lines).
The result is: 3 lines are the same, 2 lines are only in the first text and 2 lines are only in the second text, in 3 changed places. The share of lines that match is 2 × 3 ÷ (5 + 5) = 60%. The first line is shown as The quick [-brown-] fox and The quick {+red+} fox.
Word by word, The quick brown fox jumps over the lazy dog. and The quick red fox leaps over the dog! give The quick [-brown-]{+red+} fox [-jumps-]{+leaps+} over the [-lazy-] dog[-.-]{+!+}. 6 of the items are the same, so the share that matches is 2 × 6 ÷ (10 + 9) = 63.2%.
Limits you should know
- The tool compares two texts at a time. It does not merge them and does not edit them.
- Each text can have up to 1,000,000 characters. Files can be up to 5 MB.
- The work grows with the size of the texts times the number of differences. In our test on one laptop, two texts of 60,000 lines with 1 line in 100 changed took about 0.1 seconds, and two lists of 8,000 lines with the same lines in a fully different order took about 1 second. Above that amount of work the tool stops and asks you to compare smaller parts.
- A line that was moved is listed two times: as removed at the old place and as added at the new place.
- When a text has the same line many times, more than one correct list of differences can exist. The tool gives one of the shortest ones.
- From Word and PDF files only the text is compared. Layout, pictures, fonts and tracked changes are not compared. Scanned pages are pictures and cannot be read.
- The page table shows the first 500 rows and puts runs of spaces together when it shows them. The CSV file and the unified diff keep every row and every space.
- If your text holds
[-or{+itself, the marks in a changed line can be hard to tell apart from your text. Read the unified diff in that case. - The share that matches counts lines or words in the same order only. It is not a check for copied work.