Whitespace Remover
Trim, collapse, convert tabs/spaces, normalize line endings, and strip invisible characters — compose any combination, live.
About this ToolHow it works, benefits & use casesTap to collapse
The Whitespace Remover is a composable text cleaner: you pick any combination of toggles and they are applied in one predictable, ordered pass, with a live preview. Per-line options trim trailing spaces (keeping indentation), trim leading spaces, collapse runs of spaces and tabs to a single space, or remove all spaces within a line. Indentation tools convert tabs to spaces or spaces to tabs at a configurable tab size. Line options collapse multiple blank lines to one, remove blank lines entirely, or join everything onto a single line. Document options strip invisible characters (non-breaking spaces, zero-width characters, and BOM), trim the start and end of the whole text, ensure exactly one final newline, and normalize line endings to LF or CRLF. A one-click "Recommended preset" applies a sensible cleanup, and "Reset options" clears everything. Stat cards show the before and after character counts and how many were removed. The result downloads as a .txt file, and it all runs in your browser.
How to Use
- 1Optionally click "Recommended preset" to apply a sensible default cleanup, or build your own from the toggles.
- 2In "Cleanup options", pick per-line, indentation, line, and document settings — and set the tab size or target line endings as needed.
- 3Paste your messy text into the input box, or click "Load example" — the cleaned result previews live below.
- 4Check the before / after character counts and the removed/added stat card.
- 5Click "Clean whitespace", then copy or download the cleaned text as a .txt file.
Key Benefits
- Compose many cleanups in one ordered, predictable pass
- Trim trailing (keeping indentation), trim leading, collapse, or remove all spaces
- Convert tabs to spaces or spaces to tabs at a configurable tab size
- Collapse or remove blank lines, or join everything to a single line
- Strip invisible characters: non-breaking spaces, zero-width chars, and BOM
- Normalize line endings to LF or CRLF and ensure a final newline
- Recommended preset, reset, live before/after stats, and .txt download
Common Use Cases
- Cleaning copied text that arrived with non-breaking spaces or zero-width characters
- Trimming trailing whitespace and collapsing blank lines before committing code
- Converting indentation between tabs and spaces at a chosen width
- Normalizing line endings to LF for Unix or CRLF for Windows
- Flattening a multi-line snippet into a single line for a config value
Cleanup options
Per line
Keeps indentation
Within each line
Indentation
Lines
2+ → 1
Join to one line
Document
NBSP, zero-width, BOM
0 characters · live
Enter text and pick options to see the cleaned result.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- Unused CSS DetectorFind CSS selectors never matched by your HTML, see how many bytes you can save, and get cleaned CSS - with a safelist for dynamic classes
- Console.log RemoverRemove console statements from your JavaScript code
- Sort LinesSort text lines alphabetically or numerically
- Case ConverterConvert text to camelCase, snake_case, kebab-case, and more
- Character Frequency CounterCount the frequency of each character
- Find and ReplaceFind and replace text with support for regex
Options run in a fixed, deterministic sequence: line endings are normalized first, then invisible characters are handled, then indentation conversion, then per-line space trims and collapsing, then blank-line handling, then line-break removal or document trimming, and finally the target line ending is re-emitted. This ordering makes any combination of toggles predictable.
Stripping invisible characters converts non-breaking spaces (including narrow and figure spaces) into regular spaces and removes zero-width spaces, zero-width joiners and non-joiners, the word joiner, and the byte-order mark (BOM). These often sneak in from copied web content or word processors and cause hard-to-spot bugs.

