How to use the whitespace normalizer
- Paste text into the Text or code box. The sample hides a BOM, CRLF endings, trailing spaces, a non-breaking space and a zero-width space.
- Choose Line endings: LF (Unix, macOS) or CRLF (Windows).
- Set the cleanup boxes. Strip trailing whitespace, End with exactly one newline and Remove byte-order mark start on; Replace non-breaking spaces with spaces and Remove zero-width characters start off.
- Copy the Normalised text and check the counts below it.
What it does and when to use it
Invisible characters cause visible trouble. A file with Windows line endings shows every line as changed in a diff and can stop a shell script with \r: command not found. A zero-width space pasted from a web page makes a variable name or a password look right but fail. A non-breaking space breaks a YAML key or a CSV value comparison. This tool fixes all of these at once and counts what it found.
Run it before comparing files in the code diff viewer or collapsing empty lines with the blank line collapser.
How it works
The steps run in this order, in your browser:
- Remove a BOM at the very start.
- Replace non-breaking spaces and remove zero-width characters, if ticked, counting each one.
- Split the text into lines at CRLF, CR or LF.
- Strip spaces and tabs from the end of each line.
- Remove all trailing empty lines and add one newline, so the file ends cleanly.
- Join the lines with LF, or with CRLF if chosen.
CR/CRLF line endings counts the Windows and old Mac line breaks in the input.
Worked examples
These are the tool’s own outputs.
A Windows snippet. a followed by two spaces, b followed by a tab, then two empty lines, all with CRLF, becomes a, b and a final newline with LF endings. Counts: Lines trimmed: 2, CR/CRLF line endings: 4.
The sample, everything on. With both optional boxes ticked, the BOM goes, the non-breaking space in “line two” becomes a normal space, and the zero-width space before “line three” is removed: Non-breaking spaces: 1, Zero-width removed: 1.
Typography spaces. price: + a non-breaking space + 100 + a narrow no-break space + €, with the non-breaking option on and the final-newline option off, becomes price: 100 € with 2 replaced.
To Windows endings. line one and line two with CRLF chosen come out as line one\r\nline two\r\n.
Limits and tips
- Indentation and tabs inside lines are kept. To change leading tabs and spaces, use the indentation converter.
- Other invisible characters, such as right-to-left marks or the soft hyphen, are not touched.
- Git may convert line endings again on checkout if
core.autocrlfis set; fix the setting as well as the file.
Frequently asked questions
Should I use LF or CRLF?
What is a byte-order mark and why remove it?
Which hidden characters does it clean?
Why are these two options off by default?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.