Whitespace Cleaner

Trim ends, collapse spaces, remove all whitespace, remove tabs, convert CRLF/LF

Whitespace cleaner: the six cleanup actions and where they apply

What each of the six buttons does

ActionBehaviourFits
Trim endsPer line, strip leading and trailing whitespaceText copied from web pages, spreadsheets, PDFs — the most common cleanup
Collapse spacesCompress runs of spaces and tabs into a single spaceFixing misaligned text from broken layout
Remove all whitespaceDelete every whitespace character, including newlinesCompress to one line, strip spaces from identifiers
Remove tabsDelete tab characters only, keep spacesSwitch tab indentation to space indentation (but does not add spaces — see below)
CRLF to LFConvert Windows line endings to Unix line endingsCommitting to Git, running on Linux, writing shell scripts
LF to CRLFConvert Unix line endings to Windows line endingsFor old editors like Windows Notepad

The newline trap: an invisible \r silently corrupts data

Line endings are not all the same, and that is a common root of cross-platform failures:

SystemByte sequenceNote
Unix / Linux / modern macOS\n (LF, 0x0A)De facto standard; Git and most tools default to it
Windows\r\n (CRLF, 0x0D 0x0A)The historical habit of Notepad and friends
Old Mac (before OS 9)\r (CR, 0x0D)Rare now, but occasionally appears in legacy data

The most typical failure looks like this: two lines appear completely identical, yet an invisible \r is attached. The symptoms include:

So "CRLF to LF" is not merely a formatting preference; it is the first step when debugging "identical but somehow wrong" problems.

Tab-to-space is not a simple delete

"Remove tabs" only removes the tab character; it does not insert equal-width spaces. So \tif (x) becomes if (x) — the indentation level vanishes rather than turning into four spaces.

That is usually not what you want for code. To truly "tab to 4 spaces", use a replacement action: in the find-and-replace tool, replace \t (regex mode) with four spaces. A tab also matches directly as \t in regex, so the swap is straightforward.

The reverse request is also common: convert space indentation to tabs (to shrink file size or unify a team convention). That is finding (four spaces) and replacing with \t; handle it from the deepest indentation level outward, or it goes wrong. For that kind of formatting, an editor or a tool like Prettier is more reliable.

Collapse spaces does not touch newlines

"Collapse spaces" only processes spaces and tabs; it leaves newlines alone. So paragraph structure is preserved. If you also crush the newlines, the whole text becomes one line — that is the effect of "remove all whitespace".

When you need "compress several lines into one line while keeping a single space between words", the correct two steps are: first replace newlines with a space (in the find-and-replace tool, regex \s*\n\s* replaced by one space), then collapse the remaining runs of spaces.

A practical processing order

For cleaning text copied from outside, this order is recommended:

  1. CRLF to LF. Unify line endings first, so later steps have consistent assumptions.
  2. Trim ends. Strip per-line leading/trailing whitespace, clearing most formatting noise.
  3. Remove tabs or replace with spaces. Decide by the target format.
  4. Collapse spaces. Skip this if you need to preserve alignment.
  5. Drop blank lines / dedupe. Finish with the line dedupe and sort tool.

This order keeps each step's input clean, avoiding the chain reaction where "whitespace from the previous layer breaks matching in this layer". All steps happen locally in the browser.

FAQ

Does "Trim ends" work on the whole block or per line?

Per line: leading and trailing whitespace of each line is removed, while spaces inside the line are kept.

What are CRLF and LF?

Windows uses carriage return + line feed (CRLF, \r\n) as line breaks, while Unix / macOS and most code files use line feed (LF, \n). Conversion is used for cross-platform alignment.