What this tool does
Whitespace problems are the small invisible defects that make professional copy look amateur. Multiple spaces between words. Trailing whitespace at line ends. Inconsistent line endings (some \n, some \r\n). Tabs where there should be spaces, or vice versa. Empty lines that should be one or two but somehow became five.
This tool fixes all of those, with checkboxes so you can choose exactly which transformations to apply.
The five things it cleans
Collapse multiple spaces
Runs of two or more spaces between words get collapsed to a single space. The classic case is text that came from a document with double-spaced sentences ("Hello. How are you?") and needs to become single-spaced for modern web use ("Hello. How are you?"). Newlines aren't affected by this — collapsing only applies to space characters, not line breaks.
Trim each line
Trailing spaces and tabs at the end of each line are removed. Leading whitespace at the start of each line is also removed if this option is checked. Trailing whitespace is invisible in most editors but causes inconsistent line lengths, awkward diffs in version control, and broken layouts when content is embedded in code.
Remove blank lines
Lines that contain only whitespace (or nothing at all) get deleted entirely. Use this when you want the tightest possible vertical layout — for instance, converting a multi-paragraph essay into a series of single-spaced lines for a CSV import.
If you don't check this option but you do have multiple blank lines, the tool still collapses runs of 3+ consecutive blank lines down to a maximum of 2. This is usually what you want for readable prose.
Tabs to spaces
Each tab character is replaced with a configurable number of spaces (2, 4, or 8). This is essential when moving code between editors with different tab conventions, or when pasting content into systems that don't render tabs predictably.
If you need the opposite (spaces to tabs), this tool doesn't do that — use your code editor's "convert indentation" feature instead.
Normalize line endings
Windows uses \r\n line endings; macOS and Linux use \n. Mixed line endings cause subtle bugs — files that look fine but break parsers, diffs that show every line as changed, regex patterns that fail mysteriously. This option converts everything to \n, the modern standard.
Common use cases
- Cleaning text from a PDF — pasted PDF text often has erratic spacing; this tool normalizes it
- Importing CSV with messy formatting — extra whitespace inside cells breaks many parsers
- Polishing copy before publishing — final pass to ensure consistent spacing
- Preparing data for diff comparison — normalizing whitespace eliminates noise in version-controlled files
- Code cleanup — tabs to spaces for consistent indentation, trim trailing whitespace before committing
- Email cleanup — forwarded emails often accumulate awkward spacing from quoted replies
Order of operations
The transformations run in a specific order: normalize line endings first, then convert tabs to spaces, then collapse multiple spaces, then trim each line, then handle blank lines last. This order means that, for example, a tab followed by a space won't survive the "collapse multiple spaces" pass — the tab gets converted to spaces first, then the run of spaces collapses to one.
If you turn off "Collapse multiple spaces" but keep "Tabs to spaces", your tabs become explicit space runs that you can see clearly. If you turn both off, tabs and multi-space runs are preserved as-is.
What this won't fix
Invisible Unicode characters (zero-width spaces, BOMs, non-breaking spaces that look like regular spaces) aren't touched by this tool. For those, use our invisible character finder, which detects and removes weird Unicode that masquerades as normal whitespace.
This tool also won't reflow broken paragraphs from PDF copy-paste. For that specific problem, our PDF paste cleanup tool joins broken lines and de-hyphenates word-breaks.
Privacy
Everything runs in your browser. Text never leaves your machine.