Open Editor
Utility
4 min read

How a Text Diff Treats Spaces, Tabs and Line Breaks

Two texts can look the same and still differ in spaces, tabs or line breaks. Here is what ClearDiff reports for 16 test pairs, what it ignores by itself, and what it cannot ignore.

Short answer: ClearDiff compares text word by word and treats every run of spaces, tabs and line breaks as part of the comparison. An extra space, a tab in place of a space, a non-breaking space or a changed line break is reported as a difference, and since October 23, 2026 each one is drawn with a visible marker. Two things are not reported: a Windows or Unix line ending, and anything the tool has no option to ignore, such as letter case.

How the Comparison Works

ClearDiff splits both texts into words and the runs of whitespace between them, and compares the pieces exactly. Nothing is trimmed, lowercased or normalised first. The comparison runs when you click Compare, not while you type. If the texts match completely, the tool shows “✓ Texts are identical.” It does not show a count of changes, and it has no option to ignore whitespace or case.

To see what that means in practice, we ran 16 pairs of short texts on the live tool in a headless Chrome browser and recorded every highlight.

What We Found

Text A → Text BReported?
Identical textNo difference (“Texts are identical”)
One extra space between two wordsYes: the new space is added, the old one removed
A space added at the end or at the startYes
A tab instead of a spaceYes
A non-breaking space instead of a spaceYes
A zero-width space inserted between two words, so the text looks the sameYes, but as changed words (see below)
Windows (CRLF) line ending instead of Unix (LF)No: reported as identical
A line break replaced by a spaceYes
An extra blank lineYes
A trailing line break removedYes
Two sentences on one line, then on two linesYes
The same words wrapped at different line widthsYes, with extra noise (see below)
Hello World and hello worldYes: letter case counts as a difference

The Highlights Used to Be Almost Invisible

When we ran this test, a changed space was a small tinted box with nothing inside it, and a removed line break was a thin sliver about six pixels wide. In several of the 16 pairs a reader would hardly see what had changed. We changed that on October 23, 2026. In the added and removed parts of a comparison, a space now appears as ·, a tab as →, a non-breaking space as ⎍, and a line break as . Unchanged text is left as it was.

We checked that the number of highlights stayed the same for all 16 pairs, that each marker matches one character, and that the “Copy result” button copies exactly the same text as before. The markers are drawn by the page and are not part of the copied text.

Things That Can Surprise You

  • A run of whitespace is one unit. If A has three line breaks in a row and B has one, ClearDiff shows three removed line breaks and one added, not two removed. The markers show this faithfully, but it can look like more changes than there are.
  • A zero-width space is not treated as whitespace. It sticks to the words around it, so “quick”, the space and “brown” are all marked as changed, against a single merged word. The invisible character itself has no marker.
  • Windows and Unix line endings are not told apart. A text box converts both to the same line break as soon as text goes in, so the tool saw our CRLF and LF texts as identical. If you need to find a line-ending difference in a file, a text box is the wrong place to look.
  • Re-wrapping a paragraph is noisy. When we moved the line breaks in a three-line paragraph without changing a word, we got 8 highlights, and the unchanged word “to” was marked as both removed and added.
  • HTML entities are shown as typed. “Tom & Jerry” against “Tom & Jerry” is a difference, and the text is shown as it was typed, not decoded.

Very Large Texts

When the two texts together are longer than about 50,000 characters, or have so many changes that a word-by-word comparison would need too much memory, ClearDiff switches from comparing words to comparing whole lines and says so above the result. In our test a pair just over that limit switched, and the output was the same before and after our marker change. The whitespace markers apply to the word comparison, so a changed space inside a long line shows up as a changed line in that mode.

How to Ignore Whitespace or Case

ClearDiff has no “ignore whitespace” or “ignore case” option, so you clean the texts before you compare them. Two tools in ClearText Editor help: remove double spaces and remove empty lines, as explained in why remove double spaces and how to remove blank lines from text. To ignore case, convert both texts to lowercase first, as in how to convert text to uppercase or lowercase. Run both texts through the same steps, or the comparison will show the cleaning itself as a difference.

For an overview of comparing texts, see how to compare two texts and find the differences, and for a comparison of Word’s own markup with a text diff, why Track Changes is not a diff.


ClearDiff compares exactly what you give it, and that includes every space and line break. Since the markers were added, a changed space is easy to find, but the tool still cannot ignore it, and re-wrapped text will look busier than it is. Clean the texts first if the whitespace is not what you are looking for.

Related posts

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