Skip to content
gohacks.dev
Tooling

Whitespace and Invisible Character Cleaner

Strip trailing spaces, convert CRLF to LF, remove BOMs and zero-width characters, collapse blank lines and convert between tabs and spaces.

Free · No sign-up · Your inputs stay in your browser

Input

Clean up whitespace and invisible characters

Output

Cleaned text

Found 6 CRLF, 2 invisible, 2 trailing runs, 1 tabs

A CRLF in a shell script gives '/bin/bash^M: bad interpreter'; a BOM before <?php sends output before headers. Both are invisible in most editors.

Runs in this browser. Nothing you paste is sent to a server.

The bugs whitespace causes

A shell script saved with Windows line endings fails with /bin/bash^M: bad interpreter, because the kernel reads the carriage return as part of the interpreter's name. A byte order mark before <?php is output, so PHP sends headers too late and sessions break. A non-breaking space in a YAML file is not indentation, and the parser says so in confusing terms.

Keeping it fixed

Cleaning a file once does not stop the next editor from undoing it. An .editorconfig with end_of_line = lf and trim_trailing_whitespace = true is read by most editors, and * text=auto eol=lf in .gitattributes normalises line endings when files are committed.

Share

Frequently asked questions

How do I convert CRLF to LF in a terminal?
dos2unix file.sh, or sed -i 's/\r$//' file.sh with GNU sed. git config core.autocrlf input stops Git from creating them on checkout.
What is a BOM and should a UTF-8 file have one?
A byte order mark is the bytes EF BB BF at the start of a file. UTF-8 has no byte order, so the Unicode standard does not recommend one, and PHP, shells and many parsers treat it as content.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools