Why text shows up dirty more often than you'd think
Copy-paste is leaky. The simple act of moving text from one place to another picks up trailing spaces, double spaces, mismatched tabs, blank lines that shouldn't exist, and Windows line endings sneaking into Unix files. Most of the time you don't notice, until a YAML parser breaks, a markdown table fails to render, a CSV row doesn't match, or Git keeps flagging "changes" that look like nothing changed.
This tool is the opposite of a code formatter. It's surgical: pick which whitespace problems to fix and leave everything else exactly as it was. Trim trailing whitespace per line. Collapse multi-spaces. Remove blank lines. Normalize line endings. Each rule is independent.
The four most common problems
Trailing whitespace. Every line that ends with extra spaces. Invisible in most viewers but breaks YAML, breaks markdown tables, and shows up as "changed" lines in Git diffs even when nothing visible changed. Fix: turn on "Trim per-line."
Double spaces. Old typography habit (two spaces after a period) that survived into the digital era. Modern style guides use single spaces. Auto-collapse helps when you're cleaning up text written by someone with the old habit. Fix: turn on "Collapse multi-space."
Blank lines that shouldn't exist. Three blank lines between paragraphs when one is enough. Five blank lines between sections when one is intended. Most markdown editors render any number of blank lines as a single paragraph break, so the extras are noise. Fix: turn on "Collapse blank lines" (keeps one) or "Remove blank lines" (kills all).
Mixed line endings. Unix and modern macOS use \\n (LF). Windows uses \\r\\n (CRLF). When files of different origins mix in one document, Git, sed, and shell scripts get confused. Fix: pick LF or CRLF and let the tool normalize the whole document.
Trim, collapse, remove: pick the right verb
Trim removes whitespace from the edges of a line. " hello world " becomes "hello world". Always safe.
Collapse replaces runs of spaces with a single space. "hello world" becomes "hello world". Safe for prose, sometimes wrong for code that uses spaces for alignment.
Remove ALL spaces is rare. It collapses every space, internal or edge, into nothing. "hello world" becomes "helloworld". Useful when concatenating identifiers or stripping spaces from numeric strings ("1 234 567" becomes "1234567"). Almost never useful for prose.
Tabs vs spaces, the eternal debate, briefly
This tool has both options. Strip tabs removes them entirely. Tabs to spaces replaces each tab with N spaces (your choice: 2, 4, or 8 are common). Use the latter when pasting code from one editor into another with different tab settings.
The tab-vs-space debate is settled by your team's style guide, not by us. Both work. Most modern languages and editors lean toward 2 spaces. Python officially recommends 4 spaces. Go uses tabs. Use what matches the surrounding code.
Why "preserve" line endings exists
The tool offers a third line-ending option called "preserve," which best-effort detects whether the input is mostly LF or mostly CRLF and uses that style for the output. It's the safe default when you don't care which style; you just want the document internally consistent.
If you're targeting a specific platform, pick LF (Unix, macOS, web) or CRLF (Windows-only files) explicitly.
Invisible Unicode whitespace is real
Beyond the standard space and tab, Unicode defines a whole zoo of "whitespace" characters: non-breaking space (U+00A0), zero-width space (U+200B), ideographic space (U+3000), and many more. They're invisible in most editors and they almost always cause bugs.
The "Trim per-line" option uses JavaScript's \\s class, which catches non-breaking spaces, zero-width spaces, and most Unicode whitespace. So pasting from word processors, PDFs, or web pages tends to clean up automatically along with the visible whitespace.
When NOT to clean whitespace
Two cases:
Whitespace-sensitive formats. YAML, Python, Makefile, and certain command outputs depend on exact indentation. Don't run aggressive whitespace cleanup on these. Use only "Trim per-line" (which only touches edges) and never "Collapse multi-space" (which would break alignment).
Code with intentional alignment. Some teams align operator runs in source code (a = 1, bb = 2, ccc = 3). Collapsing spaces destroys the alignment. If you preserve that style, leave Collapse off.
For everything else: prose drafts, CSV cells, log lines, JSON pasted from somewhere weird, the default settings on this tool (trim, collapse multi-space, collapse blank lines, trim document edges) cover the 90% case.