Whitespace Cleaner
Remove the spaces you don't want. Keep the indentation, line endings and characters you do.
This tool processes text locally in your browser. No account or text upload is needed.Choose what to clean
Order: replace tabs → leading trim → trailing trim → collapse spaces → remove empty lines → normalize endings → final-ending policy. Only ASCII spaces and tabs are cleaned. Blank classification follows earlier transformations.
Exactly-one final ending also removes terminal blank lines; empty output remains empty. Tab replacement is a fixed number of spaces, not tab-stop alignment.
Before
0 / 2,097,152 UTF-8 bytesMaximum input: 2 MiB UTF-8. Output: 16 MiB. Process is manual; input over 32 KiB uses a cancellable local worker. Editing or changing rules clears outdated results.
After
Textareas display endings as LF. The visual marks show their original type; copy and download use the exact processed text, not the preview or decorations.
- Original UTF-8 bytes
- 0
- Result UTF-8 bytes
- Pending
- Original lines
- Pending
- Result lines
- Pending
- Lines removed by empty-line filter
- Pending
- Tabs replaced
- Pending
- Leading spaces/tabs removed
- Pending
- Trailing spaces/tabs removed
- Pending
- Repeated-space runs collapsed
- Pending
- Extra spaces collapsed
- Pending
- Line endings normalized
- Pending
- Final endings removed / added
- Pending
Drafts stay in memory only. Refresh clears them. Nonbreaking spaces, other Unicode whitespace, letters and combining characters are not normalized.
How to clean whitespace
- Paste plain text or import one UTF-8 .txt file. A single leading file BOM is removed only when the displayed import option is checked.
- Choose your rules. Only trimming trailing ASCII spaces and tabs is enabled by default.
- Choose Process text, review the before/after views and counts, then copy the complete result or download cleaned.txt.
A small example
Before: " apple \r\nbanana\t" After: " apple\r\nbanana"
The default removes two spaces after apple and the tab after banana. The two leading spaces and the original CRLF remain. No final newline is added to banana. The input is 18 UTF-8 bytes and the result is 15 bytes, with two lines in each.
Rules run in this order
- Replace each tab with 1–8 spaces, if selected. This is fixed replacement, not tab-stop alignment.
- Trim leading spaces/tabs, then trailing spaces/tabs.
- Collapse each run of two or more ordinary spaces to one.
- Remove empty lines. Space/tab-only classification is optional and happens after earlier transformations.
- Normalize surviving line terminators to LF or CRLF, or preserve each original one.
- If requested, replace every trailing CR/LF sequence with exactly one explicitly chosen LF or CRLF. Empty output stays empty.
Combining rules matters: two tabs replaced with three spaces each become six spaces. With space collapse selected, that run becomes one space, unless an earlier trim already removed it.
Line endings and blank lines
CRLF, LF and standalone CR are recognized. Each line owns its terminator. Removing a line removes its content and its own ending, without changing the remaining endings in Preserve mode. Empty input has zero lines; a final terminator does not create a phantom extra line.
Exactly-one final ending also removes terminal blank lines. It does not trim spaces from the document: whitespace-only content can remain if the selected trim and empty-line rules leave it intact. No final terminator is added unless requested.
The editable and read-only textareas display all endings as LF. Imported endings and unchanged endings during editing are retained in the tool's model. New endings typed with Enter are LF. Whitespace marks show the retained terminator types; copy uses the processed string and downloads preserve its UTF-8 bytes. A clipboard or destination application may normalize pasted line endings, so use the download when exact bytes matter.
What the counts mean
Byte counts measure the original model and complete result as UTF-8, not decorated previews. Line counts recognize the three terminator types above. Lines removed counts only the empty-line filter; the final-ending policy is reported separately.
Tabs replaced counts original tab characters expanded. Leading/trailing counts measure ASCII spaces or tabs removed at those respective stages. Repeated-space runs counts collapsed runs; Extra spaces collapsed is the number of spaces those replacements removed. Line endings normalized counts changed surviving terminators before the final policy. Final endings removed/added counts logical CRLF, LF or CR terminators replaced at the last stage.
Limits and things this tool does not change
Input is limited to 2 MiB UTF-8, including file bytes before optional BOM removal. Output is limited to 16 MiB; expansion and a final added terminator cannot bypass the limit. Nothing is silently truncated. Results longer than 65,536 UTF-16 code units have a clearly shortened selectable preview; copy and download still contain the full result. Visual whitespace marks are limited to 4,000 code units and never enter exports.
Inputs over 32 KiB run in a bundled local worker. Cancel, edits, changed options and Clear discard obsolete jobs and results. Clear, example loading and import offer in-memory Undo. Clipboard failure leaves a selectable preview with manual-copy or full-download guidance. Refreshing clears drafts.
Only ASCII space U+0020 and horizontal tab U+0009 are cleaned. Nonbreaking spaces, thin spaces, zero-width characters, letters and combining sequences are preserved. This is not a code formatter, CSV parser, HTML cleaner, grammar checker or Unicode normalizer. HTML-like input remains literal text.
How was this tool?
Help us improve Whitespace cleaner.
Opens your email app; you send it there. No email app? Copy your comment and email feedback@tooltulip.com.
Don't include sensitive data.
0/300