CRLF vs LF, Tabs vs Spaces and Invisible Characters Explained
Why line endings, tabs, trailing spaces, byte-order marks and zero-width characters break scripts and diffs, and how to find and clean them all at once.

CRLF vs LF, Tabs vs Spaces and Invisible Characters Explained
Some bugs cannot be seen. A shell script works on one machine and fails on another with a cryptic error. A YAML file looks perfect but will not parse. A search for a phrase you can see on screen finds nothing. Very often the cause is a character that has no visible shape. The free Whitespace and Line Ending Fixer shows every one of them and cleans them up.
Line endings
Text files mark the end of each line with control characters, and operating systems disagree on which:
- LF (line feed) on Linux, macOS and almost all developer tools.
- CRLF (carriage return then line feed) on Windows.
- CR alone on classic Mac OS before 2001.
Problems appear when files cross systems. A script saved with CRLF fails on Linux because the shell sees the carriage return as part of the command name, giving errors like "bad interpreter". Diffs show every line as changed when one person's editor converts the endings. Files with a mixture of both are worse still.
Git can handle this for you. A .gitattributes file with * text=auto normalises endings in the repository, and lines like *.sh text eol=lf force LF for scripts regardless of the platform.
Tabs and spaces
Indentation style is mostly a matter of taste, but some formats have firm rules. YAML forbids tabs for indentation. Python raises an error when tabs and spaces are mixed inconsistently. Makefiles require a tab before each command. The fixer converts in either direction and respects tab stops, so alignment is preserved rather than shifted by a fixed number of spaces.
Trailing whitespace and final newlines
Spaces at the end of lines are invisible, but they create noise in code reviews and occasionally change meaning, for example two trailing spaces mean a line break in Markdown. Many style guides also require exactly one newline at the end of a file, because some tools ignore or mishandle the last line otherwise.
Invisible Unicode characters
Text copied from web pages, PDFs and word processors carries extra characters:
- No-break spaces look like normal spaces but are different characters, so searches and comparisons fail.
- Zero-width spaces and joiners have no width at all. They break identifiers and passwords copied from documents.
- Byte-order marks at the start of a file confuse JSON parsers, CSV headers and shebang lines.
- Bidirectional control characters change the display order of text. In 2021, researchers showed they could make source code appear to do one thing while the compiler sees another, an attack called Trojan Source.
Some of these characters are legitimate: zero-width joiners build family and skin-tone emoji, and bidirectional controls are needed in some Arabic and Hebrew text. Remove them from code and data, but think before stripping them from prose.
Preventing the problem
An .editorconfig file at the root of a project tells most editors which line ending, indentation style and width to use, and whether to trim trailing whitespace and add a final newline. Combined with a formatter in continuous integration, it stops these issues from coming back.
Using the fixer
The report counts each line ending type, indentation style, trailing whitespace and every kind of invisible character. The visible view replaces spaces with dots, tabs with arrows and hidden characters with markers so you can see exactly where they are. Choose the fixes, check the before-and-after table, and download the cleaned file.
Step by step
- Paste text or open a file.
- Read the counts in the report.
- Inspect the visible view for anything unexpected.
- Choose a line ending, indentation and cleaning options.
- Download the cleaned file.
Privacy
The tool reads your text locally in the browser and never uploads it.



