Compare Text

Published Updated

Paste two versions of a text and see which sentences were added, removed or changed, with the edited words marked inside each changed sentence.

Sentences first, then words

This checker breaks both texts into paragraphs at blank lines and each paragraph into sentences, then lines the two lists up with Myers' difference algorithm, described in An O(ND) Difference Algorithm and Its Variations (1986). It is the same method git diff uses unless told otherwise. Its cost grows with the number of differences, so two drafts that are mostly alike compare quickly.

When a sentence on the left is paired with one on the right, the same algorithm runs again on their words and spaces, and only the words that differ are highlighted. The summary line counts the result in pieces, for example 0 additions, 0 removals, 1 change.

One edit at a time

These results come from running the tool's own diff code on the text shown:

OriginalRevisedShown as
The fee is $40 per month.The fee is $45 per month.1 change: $40 struck in red, $45 in green
Payment is due in 30 days.Payment is due in 30 days.Unchanged
One. Two. Three. Four.One. Two and three. Four.2 removals and 1 addition, no word marks
Send it to Anna.Send it to anna. (two spaces before anna)1 change: the space and the name both marked
apples, bananas, cherries on three linesapples, blueberries, cherries on three lines1 change: bananas to blueberries

What it does not do

There is no option to ignore case, spacing or punctuation, no line-by-line mode, no file upload and no way to accept or reject an edit. Line breaks inside a piece show as spaces in the result table, while the copied text keeps them.

For lists whose items moved around, sort both versions first with Sort Lines Alphabetically, so only real additions and removals remain. For PDF files, Compare PDFs extracts the text and applies the same comparison.

How each kind of edit is shown

We ran pairs of texts through this page's comparison tool in Google Chrome 157, Firefox 155 and Playwright's WebKit build (not the Safari app) and read the summary line and every row of the result. The three browsers showed the same result for every pair. Marked words are in brackets here: [-old] on the original side, [+new] on the revised side.

EditOriginalRevisedSummary lineWhat the result shows
Case of one wordSend it to Anna.Send it to anna.1 change[-Anna.] and [+anna.]: the full stop belongs to the word, so it is marked too.
A tab or a no-break space instead of a spacePay 40 USD today.Pay 40 USD today. (no-break space after 40)1 changeOnly the space is marked, which looks like an empty highlight.
é typed as e plus a combining accentMeet at the café.Meet at the café.1 change[-café.] and [+café.], although both sides look the same.
Straight or curly apostropheDon't stop.Don’t stop.1 changeThe whole word is marked: [-Don't] and [+Don’t].
Comma addedHello worldHello, world1 change[-Hello] and [+Hello,].
Word insertedPay the invoice.Pay the overdue invoice.1 change[+overdue] and the space after it, on the revised side only.
Sentence insertedOne. Three.One. Two. Three.1 additionTwo. on a row of its own.
Paragraph moved to the endAlpha one. / Beta two. / Gamma three., one per paragraphBeta two. / Gamma three. / Alpha one.1 addition, 1 removalAlpha one. removed at the top and added at the bottom. There is no moved marker.
Two sentences swappedFirst point. Second point.Second point. First point.1 addition, 1 removalFirst point. removed before Second point. and added after it.
Word changed after a quoted sentenceHe said "Stop." Then he left.He said "Stop." Then she left.1 changeThe closing quote stays with "Stop.", so the next piece starts at Then: Then [-he] [+she] left.

Three dots and ?! end a piece, as in Wait... | what?! | Fine., while the single ellipsis character … does not.

Copy Comparison writes plain text: a changed piece as its old version after a minus sign and a space, then its new version after a plus sign and a space, and an unchanged piece after two spaces. Line breaks inside a piece are kept, and each line gets the sign of its piece. A three-line list apples, / bananas, / cherries. changed to blueberries, followed by an unchanged sentence, was copied as seven lines: - apples, - bananas, - cherries. + apples, + blueberries, + cherries. and Same end. after two spaces.

Changes that are not reported

Each piece is trimmed, and the paragraphs are flattened into one list of sentences before the comparison. So these edits gave No differences found in all three browsers:

OriginalRevisedResult
Two spaces before Hello world. and three after it, then Next line.Hello world. and Next line. with no extra spacesNo differences found
One. Two.One., a blank line, Two.No differences found
A first., one blank line, B second.The same with four blank linesNo differences found
Lines ending in Windows line breaks (CR LF)The same lines ending in LFNo differences found, because the text box hands the page LF only
Line one, a line break, Line two (no full stops)Line one, a blank line, Line two2 additions, 1 removal: without full stops the blank line does split the piece

So a paragraph break added or removed between complete sentences has to be checked by eye.

How long a comparison takes

Generated texts of 8 to 15 words per sentence, with a blank line after every fifth sentence. The edited versions had 6 to 8% of their sentences changed, removed or added. Time from the click on Compare Text until the result appeared, median of 5 runs on one computer:

Texts comparedCharacters, both boxesChrome 157Firefox 155WebKit build
250 sentences and an edited copy (16 edits)41,7258 ms9 ms10 ms
1,000 sentences and an edited copy (78 edits)164,12930 ms34 ms35 ms
2,000 sentences and an edited copy (135 edits)333,14555 ms65 ms70 ms
4,000 sentences and an edited copy (278 edits)668,662122 ms156 ms143 ms
Two unrelated texts of 1,000 sentences each165,419178 ms258 ms248 ms
Two unrelated texts of 2,000 sentences each333,387394 ms594 ms516 ms
Two unrelated texts of 4,000 sentences each670,092930 ms1,534 ms1,164 ms
One block of 19,999 characters per side, no full stops, no shared words39,998214 ms361 ms185 ms
The same with 20,001 characters per side40,0024 ms4 ms2 ms

How much differs matters more than length: two unrelated texts of 4,000 sentences took 8 to 10 times as long as 4,000 sentences and an edited copy. Above 20,000 characters a block is shown without word marks, which is why the last row is fast. With 4,001 and 4,000 sentences (8,001 pieces), every browser showed within 12 ms: "This text has too many paragraphs/sentences to compare in the browser (8001 combined, max 8000). Please try shorter text."

Checking what changed

  1. Step 1

    Paste both versions

    Original on the left, revised on the right. Together they may hold up to 8,000 sentences and paragraphs.

  2. Step 2

    Compare and read

    Removed text is red and struck through, new text is green, and a changed sentence marks only the words that differ. Show only differences hides the rest.

  3. Step 3

    Copy the comparison

    The copy is plain text: a minus before removed units, a plus before added ones, two spaces before unchanged ones.

Comparing text: what to expect

Does it compare line by line like a code diff?

No. It splits the text at blank lines and after full stops, question marks and exclamation marks, then compares those pieces. A single line break splits nothing, so an unpunctuated list counts as one piece, though the changed words inside it are still marked.

Does it ignore capital letters or extra spaces?

No. Anna and anna count as different, and so do one space and two between words. Both show up as changes, and there is no switch to ignore them. Spaces at the start or end of a line and extra blank lines between sentences are the exception: each piece is trimmed, so they are not compared.

Why is an edit shown as removals and an addition with no word marks?

Word marks appear only when a run of removed sentences is matched by the same number of added ones. When two sentences are merged, as Two. Three. becoming Two and three., the result is two removals and one addition.

Is 3.5 split at its decimal point?

No. A full stop ends a piece only when white space or the end of the text follows it, so Dr. Lee paid 3.5 million. is read as two pieces, Dr. and the rest. Changing 3.5 to 3.6 is shown as one change with 3.5 and 3.6 marked.

How much text can it handle?

Up to 8,000 sentences and paragraphs across both boxes; above that you get a message asking for shorter text. A single piece longer than 20,000 characters is still compared, but it is shown as wholly removed and added, without word marks.

Can I compare two PDFs or Word files?

Paste their text here. For PDFs, Compare PDFs reads the files for you and runs the same comparison on their text.

Why does it say No differences found after I added a paragraph break?

Paragraphs are split into sentences and the sentences are compared as one list, so a blank line between two complete sentences changes nothing: One. Two. against One., a blank line, Two. gave No differences found in Chrome 157, Firefox 155 and the WebKit build. Extra blank lines, spaces at the start or end of a line and Windows line breaks were not reported either.

Does it show a moved paragraph as moved?

No. Moving the first of three paragraphs to the end gave 1 addition and 1 removal: the paragraph is struck at the top and shown as new at the bottom. Two swapped sentences give the same pair of rows.

Why is a word marked when both sides look the same?

The characters differ even if the letters look alike. A tab or a no-break space in place of a space, an é typed as e plus a combining accent, and a curly apostrophe in place of a straight one were each reported as 1 change, with the space or the word marked.

How long does a long comparison take?

4,000 sentences against an edited copy (668,662 characters in all) took 122 ms in Chrome 157, 156 ms in Firefox 155 and 143 ms in the WebKit build. Two unrelated texts of 4,000 sentences each took 930 ms to 1,534 ms. One more sentence on either side of those goes over the limit of 8,000 pieces and shows a message instead.

Related Tools