Skip to content

Compare two texts

Paste the original on the left and the changed version on the right. Changed lines and words light up at once.

Original
Changed
Paste two texts to see the differences.

The result appears here. Removed lines get a - sign, added lines a + sign, and changed words are marked inside the line.

Saved in this browser Both texts stay on this device. Nothing is uploaded.
Advertisement
Two sheets of paper side by side with one differing line marked on each

Last checked by the TextEditor.com team

What a diff is

Diff is short for difference. It is a program that takes two versions of a text and shows which lines changed. James Hunt and Douglas McIlroy wrote the first diff at Bell Labs in 1976 for Unix. It looks for the longest run of lines that both versions share, in the same order. Every line outside that run was added or removed.

Eugene Myers published a faster way to find that run in 1986. Most tools, including Git and this page, still use his method. Try it: change a word in either box and watch the result.

Two shopping lists, compared
Original on the left, changed text on the right
1-Bring milk1+Bring oat milk
2-Bring eggs
3Bring bread2Bring bread
3+Bring apples

1 addition, 1 deletion, 1 changed line

How to read a side by side diff

The original is on the left and the changed version on the right. Each side keeps its own line numbers, so a line can be number 7 on the left and number 9 on the right.

What each row means
Example rows of a side by side diff
4Open from 9 to 5.4Open from 9 to 5.
5-Closed on Sunday.
5+Open on Sunday until noon.
6-Call 555 0100 to book.6+Call 555 0199 to book.
… 12 unchanged lines
  1. No sign, plain row: the line is the same in both versions.
  2. Minus sign, warm tint: the line was removed. The right side is empty.
  3. Plus sign, green tint: the line was added. The left side is empty.
  4. Both signs, marked words: the line was edited. Only the marked words differ.
  5. Folded row: with "Only differences" on, unchanged runs fold into one row. Click it to see them.

The unified view puts both texts in one column, removed lines first, then added lines. It is the same layout that Git and code review tools use. The arrows above the result jump from change to change, which helps in a long document.

Line, word or character

By default the tool compares lines, then marks the changed words inside each changed line. That is the right choice for code, lists and anything with short lines. For prose, pick "word": the whole text is one stream, so a sentence that moved to another line is not a change. Pick "character" for short strings like a name, an address or a serial number, where one wrong letter matters.

The same two sentences, three ways
The quick brown foxcat jumpsjumped over the lazy dog. It was a sunny afternoon.

By word, two words changed. By character, only the letters that differ are marked, so "jumps" and "jumped" share "jump".

What people compare

  • Essay drafts. Paste the version you sent and the version that came back to see every edit. The word counter tells you how much longer the new draft is.
  • Contracts and terms. A new version of a contract often changes one number or one word. Turn on "Ignore whitespace" so a reformatted paragraph does not hide the real change.
  • Code and config files. Open both files, compare by line, then copy the unified diff into a bug report. For editing, use the code editor.
  • Translations. Compare the first draft with the proofread version to learn what the reviewer changed.
  • Lists. Two exports of the same list, a price list from last month and this month, or a guest list before and after edits. "Ignore case" and "Trim line ends" remove the noise from copy and paste.

Typing a draft first? The plain text editor saves it in your browser, and you can paste it here later.

The unified diff format

"Copy as unified diff" gives you the result as text in the format that the Unix diff command prints with the -u flag. Git, code review tools and the patch program all read it, and it pastes well into an email or a bug report.

A unified diff, line by line
--- original.txt
+++ changed.txt
@@ -4,3 +4,3 @@
 Open from 9 to 5.
-Closed on Sunday.
+Open on Sunday until noon.
 Call 555 0100 to book.
  • --- and +++ name the original and the changed file.
  • @@ -4,3 +4,3 @@ is a hunk header: this part starts at line 4 and covers 3 lines in the original, and starts at line 4 and covers 3 lines in the changed text.
  • A space starts an unchanged line, a minus a removed line, a plus an added one. Unchanged lines around a change give the reader some context.

What a diff can't tell you

A diff matches lines in order. A paragraph that moved to another place shows up as removed in one spot and added in another, even if not one word changed. A paragraph with new line breaks but the same words shows as changed in line mode. Switch to word mode and it disappears.

The ignore options cover case, spacing and blank lines. The tool does not know that "colour" and "color" mean the same thing, and it does not understand Word formatting. For .docx files, copy the text out of Word, or open the file in the Word editor and copy it from there.

Speed is not a problem for normal documents. Two texts of 5,000 lines compare in well under a second. Above 200 KB the live update stops and you press Compare instead.

Get two texts ready to compare

Frequently asked questions

How do I compare two text files for differences?

Click Open file on each side, or drop both files on the page at once. The first file goes to the left, the second to the right. Then press Compare, or Ctrl+Enter. Changed lines are marked with a plus or a minus sign.

Can I compare two Word documents?

Not the .docx files themselves, since they are not plain text. Open each document in Word, select all, copy, and paste the text here. Word also has its own Compare command under the Review tab, which tracks formatting changes too.

What do the red and green colors mean?

A warm red tint with a minus sign marks a removed line. A green tint with a plus sign marks an added line. A line shown on both sides with marked words was edited. Every change also has a sign, so the result works without color.

Is my text uploaded to a server?

No. The comparison runs in your browser. Both texts are saved in this browser only, so they are still here when you come back. Nothing is sent to us.

Can it compare code?

Yes. Open the two files, keep "Compare by line", and turn on "Trim line ends" if the editor changed the indentation. "Copy as unified diff" gives you a patch you can paste into a bug report or apply with Git. For editing the files, see the code editor.

  • Text editorWrite and edit plain text in your browser.
  • Readability checkerCheck the reading grade level of your text.
  • Code editorWrite or paste HTML, CSS, JavaScript, JSON, Python, SQL and more with colors, line numbers and a format button.
  • Case converterPaste text and change it to UPPERCASE, lowercase, Sentence case or Title Case in one click.
  • HTML editorWrite in a visual editor and get clean HTML code.
  • NotepadKeep several notes in one place.

↑ ↓ to choose, Enter to open, Esc to close