Skip to main content
CalcChef

Text Diff Tool

Text diff tool that compares two texts by line, word or character and marks what was added and removed. It can ignore whitespace, case and line endings. How it works

Use the Text Diff Tool

Limits: 1,000,000 characters per side; Words and Characters modes also take at most 5,000 lines per side. Files are read in your browser and are not uploaded.

Compare by

Difference

2 lines added, 1 removed, 2 unchanged.

Result layout
Line by line differences with old and new line numbers
Original lineNew lineChangeText
1removedThe quick brown fox
1addedThe quick brown cat
22unchangedjumps over the lazy dog.
33unchangedSee you at noon.
4addedBring lunch.

A + marks a line only in the new text, a − a line only in the original. A changed line shows as one − line and one + line; words that changed inside it are bold.

A comparison, including the word highlighting inside changed lines, is held to 8 seconds. If the texts are too different to compare in that time you get a message; word highlighting that does not fit is skipped for the remaining changed lines, and it is only done for the first 400 pairs of changed lines of up to 1,000 characters. Characters mode counts Unicode code points.

About the Text Diff Tool

Paste the original text in the first box and the new text in the second, and the text diff tool marks every line that was added (+) or removed (−) and bolds the words that changed inside a line. It also compares word by word or character by character, and tells you when two texts are identical or differ only in line endings, whitespace or letter case.

Why two texts that look the same compare as different

What differsLines mode with the default optionsWith the matching option changed
Line endings in two loaded files: CRLF in one, LF in the otherThe two texts are identical apart from line endings (CRLF/LF).Ignore line endings off: 2 lines added, 2 removed, 0 unchanged. The two texts differ only in line endings (CRLF/LF).
An extra space: “a b” against “a b”1 line added, 1 removed, 0 unchanged. The two texts differ only in whitespace.Ignore whitespace on: The two texts are identical apart from whitespace.
Letter case: “Hello” against “hello”1 line added, 1 removed, 0 unchanged. The two texts differ only in letter case.Ignore case on: The two texts are identical apart from letter case.
A final line break present in one text only1 line added, 1 removed, 1 unchanged. The two texts differ only in a final line break.Ignore whitespace on: The two texts are identical apart from a final line break.

Each cell is the summary line the tool prints. The line-ending and final-line-break rows use two lines, “a” and “b”. Line endings can differ only between loaded files, because text pasted or typed into a box always has LF line breaks.

The sample texts compared in each mode

ModeSummaryIn the copied text
Lines2 lines added, 1 removed, 2 unchanged.@@ -1,3 +1,4 @@
Words3 words added, 1 removed, 12 unchanged.The quick brown [-fox-]{+cat+}
Characters16 characters added, 3 removed, 59 unchanged.The quick brown [-fox-]{+cat+}

The tool opens with these texts: three lines in the original, and a new text that changes “fox” to “cat” in the first line and adds a fourth line, “Bring lunch.” Lines mode copies a unified diff. The other modes copy the text with removals in [- -] and additions in {+ +}.

Frequently asked questions

How do I compare two text files?
Press Load a file above each box and choose the two files, or paste their contents. The differences appear below. Each file is read in your browser and is not uploaded. It has to be UTF-8 text; a Word document or PDF has to be saved as plain text first.
Why do two files that look identical show differences?
Usually line endings (Windows CRLF against Unix LF), trailing spaces or tabs, a missing final line break, or letter case. This tool names the cause in its summary, for example “The two texts differ only in whitespace.” Line endings differ only between loaded files, since text pasted or typed into a box always gets LF line breaks. They are ignored by default, so turn that option off to see them.
Is this a side-by-side diff?
In Lines mode, yes: choose Side by side and the original is on the left, the new text on the right, with line numbers on both. A changed line sits across from its new version; a line only in one text has an empty cell on the other side. One column, the default, is a single list: removed lines marked − with the original line number, added lines marked + with the new line number, and unchanged lines between them. Words and Characters modes show one column.
What is a unified diff?
The format that diff -u prints: two header lines starting --- and +++, then hunks that open with a line such as @@ -1,3 +1,4 @@ and list lines prefixed with a space (unchanged), - (removed) or + (added). Copy as unified diff produces that for the Lines comparison, with three lines of context around each change. A text that does not end with a line break is marked with a line saying there is no newline at end of file.
Can it ignore whitespace or capital letters?
Yes. Ignore whitespace differences treats runs of spaces and tabs as one space in Lines and Words modes. Ignore case treats capitals and small letters as equal. With both on, “Total: 10” and “total: 10” count as the same line.
How large a text can it compare?
Up to 1,000,000 characters per side, and loaded files up to 4 MB. Words and Characters modes also stop at 5,000 lines per side, and a comparison that runs longer than 8 seconds is stopped with a message that suggests Lines mode or smaller pieces.

Related Tools

View all tools