PasteDiff


Whitespace, tabs, and line endings, including CRLF and LF

A packing list for a community fridge looked the same on two laptops and failed a comparison anyway. One file had been saved by Windows Notepad. The other had been saved on a Mac. A third copy had been pasted from a group chat on a phone. The words were “oat milk,” “eggs,” and “rice.” The invisible characters between them were not the same characters. Anyone who has reconciled a spreadsheet export with a hand-edited list has met this, usually late, usually convinced the list itself was wrong.

Whitespace is any character that separates words without drawing a letter: the ordinary space, the tab, the line break, and a handful of lookalikes. Line endings are the specific characters that mean “this line stops.” They are the reason two files with the same words can still be a noisy diff.

The ordinary space is only one of the spaces

The space bar inserts U+0020, the character almost every counter includes when it says “with spaces.” Word processors also insert non-breaking spaces so “2 dozen” does not split at the end of a line. A non-breaking space looks like a space. It is a different code. Paste one list that used ordinary spaces and one that used non-breaking spaces into the comparison page, switch to character mode, and the highlights sit on those gaps. In word mode the summary will often say that spacing or punctuation changed, because a space is not counted as a removed word. That sentence is the clue. The lists were not “the same words in a different order.” They were the same words joined by different glue.

Double spaces are the mundane version. Two spaces after a period used to be taught in typing class. One space is what most editors want now. Word mode will not call that a word change. Character mode will mark one of the spaces. If you are cleaning a draft, the Edit both menu can collapse repeated spaces and extra blank lines in both boxes at once. That edit happens in the browser. It rewrites the boxes. Compare again afterward so you are looking at the cleaned text rather than at the spaces you just removed.

A tab is not “several spaces.” It is one character that a display may draw as a wide gap. A list that aligned prices with tabs will look like a table until you paste it into a page that shows tabs as a single gap or as a symbol. In character mode a tab and four spaces are a real difference, even when the columns looked even on the original screen. If you meant columns, you do not want to convert tabs to spaces blindly. If you meant a sentence, you do. Decide that before you let an editor “fix indentation” across a whole file.

CRLF and LF are two ways to end a line

Historically, a line ending on Windows is two characters: a carriage return (CR) and a line feed (LF). On Linux, macOS, and most tools that grew up on the web, a line ending is only the line feed. The pair is called CRLF. The single character is called LF. A file can also, rarely, use CR alone, which is an old Macintosh convention you still meet in exports from elderly systems.

You cannot see the extra character. You can see its effects. A program that counts “characters including line breaks” will count two characters per line on a CRLF file and one on an LF file. A 40-line packing list is 40 characters apart before anyone adds oat milk. A comparison that does not normalize line endings will mark the end of every line. The words look unchanged and the screen is covered in highlights. That is a correct report of the bytes and a useless report of the shopping.

PasteDiff treats a line break as whitespace. In word mode, a CRLF-versus-LF difference tends to show up as a spacing note rather than as dozens of fake word edits, because the words still match. In character mode you will see the break itself. If you need the words and the line-ending noise is in the way, use Edit both and choose “Replace line breaks with spaces,” or compare after you have saved both copies with the same ending. The point is to choose. Leaving the endings mixed and then arguing about the diff is how a fridge list turns into a debate about software.

Editors and Git often have a setting to convert CRLF to LF on save. Two people with different settings will “change” every line of a shared note without editing a word. If you collaborate, agree on LF unless a Windows-only tool demands CRLF. Write the agreement down next to the file, not in a chat that will scroll away. The note on simple version control for writers is about that kind of agreement, not about learning Git commands you will not use.

A packing list, taken apart

Here is the list as a person thinks they typed it:

oat milk eggs rice

Here is a version that has been through a spreadsheet and a phone:

oat milk eggs  rice

The first line of the messy version uses a tab between “oat milk” and “eggs,” then a non-breaking space. “Rice” is followed by a bare carriage return. Displayed in a patient editor, some of this looks like three items. Displayed in another, “eggs” sits on the same line as the milk. Character mode shows the tab, the odd space, and the break. Word mode shows that the words are still those three words if the breaks still separate them, or that “eggs” glued itself to the line above if a break was lost.

Clean this kind of paste before you treat the comparison as a content review. The cleaning guide shows how PDF hyphenation and web formatting add a second layer on top of CRLF. Once the invisible characters match, a real edit, such as someone changing “rice” to “brown rice,” is the only highlight left. That is the edit the fridge actually needs.

What to do when every line lights up

If Compare paints the end of every line and the words are unchanged, you are looking at line endings or at trailing spaces, not at a rewrite. Switch to word mode and read the summary. If it says the spacing or punctuation changed, and the word counts match, stop hunting for a missing item. Normalize the breaks, or turn line breaks into spaces if the text was never really a list, and compare again. If a word count moved, then an item did change, and the whitespace was camouflage.

Keep one canonical copy of a list that matters: the same line ending, ordinary spaces, no trailing gap on the last line. Copy from that file. The next phone paste will try to be clever again. You will at least know which side introduced the cleverness, because the other side will still be the file you saved on purpose.