Skip to content
HexSlate

Whitespace Remover

Your text0 B / 2 MB

Nothing to clean yet

Paste text into the box on the left and the result appears here.

0 code units in0 code units out0 removed0 lines in, 1 out0 invisible characters

The characters you cannot see

Every invisible character is named rather than silently deleted, with its code point, count and first line: Unicode space separators, zero-width format characters, bidirectional controls, and the five line breaks that are not \n or \r\n.

Non-breaking space, U+00A0. Word inserts it on Ctrl+Shift+Space, copying from a rendered page turns every   into one, and PDF extraction produces them wherever the layout engine had a fixed gap. It looks exactly like a space and is not one, so split(' ') does not split on it and a CSV field reading New York stops matching your database.

Zero-width space, U+200B. CMSes and chat apps insert it inside long URLs to give the browser a place to wrap, and a copied value then fails a comparison that should pass. trim() removes U+00A0 but not this: U+200B is a format character, not whitespace, so it survives every trim, every replace(/\s/g, '') and most validation. A zero-width joiner, U+200D, inside an emoji sequence is the mechanism rather than a fault, so joiners with an emoji on either side are left alone.

Byte order mark, U+FEFF. PowerShell 5.1 writes one by default, as do older Notepad and Excel's "CSV UTF-8" export. A CSV parser then reports the first column missing, a shell script fails with "bad interpreter" because the kernel no longer sees a shebang on byte zero, and JSON.parse throws at position 0. The same code point elsewhere in the file is a zero-width no-break space, not a BOM.

A tab is a tab stop, not four spaces

Converting tabs to spaces means advancing to the next tab stop. At width 4, the tab in a\tb produces three spaces, because "a" already used a column. Tools that emit four every time are why a detabbed file comes back misaligned; this one tracks the column, matching GNU coreutils expand. Going the other way, only leading indentation converts, matching unexpand without --all: runs of spaces mid-line are usually alignment, and tabbing those breaks it at any other tab width. While either conversion is on, trimming and collapsing leave the leading indentation alone, since that indentation is the thing being converted and removing it in the same pass would leave the setting nothing to do.

Common problems

  • A line still looks empty, or trimming leaves something behind. It holds a non-breaking space or another invisible character. Trimming removes spaces and tabs only, so the rest gets named instead of vanishing.
  • Two strings look identical but do not compare equal. Paste both here. If one lists a zero-width character and the other does not, that is your answer.
  • Mixed line endings. Lines are rejoined with the ending each already had, so a mixed file stays mixed until you set Line endings to LF or CRLF.

Frequently asked questions

Does my text get uploaded anywhere?

No. Only your settings go in the URL, so a shared link reproduces the configuration and not the content.

What is the difference between LF and CRLF?

LF is a single newline, used by Linux, macOS and every modern toolchain. CRLF is a carriage return plus a newline, the Windows and HTTP convention. The wrong one shows as one long line in some editors, or a stray character at the end of every line in others.

Will this break my emoji?

Not in cleaning mode. A zero-width joiner between two pictographic characters is left in place. Strip all whitespace is the exception: it removes every whitespace and format character, joiners included.

What is the character my editor cannot see?

Usually a non-breaking space, U+00A0, pasted in from a word processor or a web page. It looks exactly like a space, it is not one, and it breaks string comparisons, CSV columns and code. This page names every invisible character it finds rather than silently deleting it.