Open Editor
Utility
4 min read

Comparing Large Texts: When ClearDiff Switches to Line Mode

Above 50,000 characters ClearDiff stops comparing words and compares lines. Here is how fast it is from 100,000 to 10 million characters, when the page freezes, and the one case that gives a useless result.

Short answer: ClearDiff compares text word by word as long as the two texts together are 50,000 characters or fewer. Above that it compares line by line, and a changed line is shown as removed and added whole. In our tests, comparing 100,000 characters took under 60 milliseconds and 10 million characters took 1 to 2 seconds. The catch: if a long text has no line breaks, three changed words show as the entire paragraph replaced.

The Rule

The tool adds the lengths of text A and text B. If the total is above 50,000 characters it uses line mode; at exactly 50,000 it still compares words. Two other limits can also push it to line mode: if the table needed to compare the words would be larger than 160 MB, it switches to lines. In line mode it uses the same kind of table when it fits in 160 MB, and otherwise a different method that works as long as there are no more than 5,000 edits. Past that, or after 9 seconds, it shows a message instead of a result. There is no maximum text size.

When line mode is used, the tool says so: “Large text: compared line by line, so a changed line is shown as removed and added.”

How We Tested

On October 28, 2026 we generated pairs of texts from a fixed list of 2,000 invented words and compared them on the live tool in a headless Chrome browser. In each pair, text B was text A with three single words replaced (near the start, the middle and the end), or with a block of 20 lines inserted, or was completely different. Sizes ran from 20,000 to 10 million characters combined. Each run was timed from the click on Compare until the result was painted. For every run we also took the “Copy result” text and rebuilt both originals from it; all 25 runs rebuilt exactly.

Word Mode and Line Mode Side by Side

Combined sizeModeThree changed words are shown as
49,990 charactersWordThree removed words and three added words
50,010 charactersLineThree removed lines and three added lines (about 70 to 80 characters each)

Twenty inserted lines also look different. In word mode the tool reported 187 and 193 words added, drawn as hundreds of small highlights, one for each word and each gap. In line mode it reported 20 lines added, one highlight per line.

The One-Paragraph Pitfall

Line mode treats everything between line breaks as one unit. If your text has no line breaks, such as a single long paragraph, the whole text is one line. With the same three one-word changes, a pair of 100,000 characters showed 1 line removed and 1 line added, each 50,000 characters long. At 10 million characters it was two spans of 5 million characters.

The result is correct, since the Copy result text rebuilt both originals, but it tells you nothing about where the change is. If you need to find small changes in a long unbroken text, put line breaks into both texts first, for example one sentence per line, and compare them in the same way. If both texts are 50,000 characters or fewer together, the problem does not arise.

Speed

Combined sizeTime to result
100,000 characters35 to 57 ms
500,000 characters97 to 208 ms
2 million characters207 to 436 ms
10 million characters0.96 to 1.98 seconds

The range in each row covers the line-based, paragraph, inserted-block and (up to 500,000) completely different texts. A completely different pair of 500,000 characters gave 3,245 lines removed and 3,243 added in 208 ms. Two identical texts of 2 million characters returned “Texts are identical” in 106 ms.

The Page Freezes Briefly

The comparison runs in a background thread, so the page should stay responsive, but it does not entirely. Sending the texts over and drawing the result block the page. The longest block we measured was about 260 ms for 2 million characters of normal lines and 372 ms for the same size as one paragraph. At 10 million characters it was 617 ms, and 1.75 seconds for one paragraph. The page recovered each time. We measured only the page’s own memory, 11 to 131 MB, not the background thread’s.

A 50 MB Text

We loaded a 50 MB text into one box. It took about 3.6 seconds to appear and the tool showed no warning. Comparing it with an empty second box took about 15 seconds, longer than the 9-second limit, but the result still arrived: 680,295 lines removed and 1 line added, because an empty box counts as one empty line. We did not see either of the two error messages in any test. Treat 50 MB as the edge of what is sensible in a browser tab, not as a recommended size.

What we could not see: the page does not show which method it used inside line mode, so we do not state it. The test words are invented, and real text with more repeated lines may behave differently. For comparing text that differs only in spaces and line breaks, see how a text diff treats spaces, tabs and line breaks; for a general overview, how to compare two texts and find the differences.


ClearDiff is fast even for very large texts, and its output stays exact. The limit is not speed but detail: above 50,000 characters you see changed lines, not changed words, and a text without line breaks is one line. Add line breaks before you compare.

Related posts

For questions or inquiries contact us at info@cleartexteditor.com