Remove Extra Spaces (Whitespace Tools)
Trim, collapse and normalize spaces, tabs, empty lines and invisible characters — entirely on this device.
Operations always run in one fixed order: strip zero-width → normalize exotic spaces → convert tabs → trim line ends → collapse runs → remove empty lines → remove all whitespace. Normalization runs first on purpose: converted and un-split spaces join runs, so they collapse too.
Press ? for shortcuts
Do it offline:$ sed -E 's/[[:blank:]]+/ /g' file.txt
How to use it
- Paste text into the input pane, or open a file with the file picker — either way the content stays on this device.
- Tick the cleanups you want. They always run in the fixed order the stack lists them: strip zero-width, normalize exotic spaces, convert tabs, trim line ends, collapse runs, remove empty lines, remove all whitespace.
- Switch on the invisibles overlay: each space, tab, break and hidden code point becomes a glyph, and whatever the current options will change is marked in advance.
- Copy or download the cleaned text, or share the tool state as a link; sharing asks first if the input looks credential-shaped.
Extra spaces rarely travel alone: pasted text hides non-breaking spaces, zero-width characters, stray tabs and doubled blanks that no editor shows you. Tick the cleanups you need — collapse runs, trim line ends, convert tabs, strip invisibles, drop empty lines — and read the result live, with an overlay that marks every invisible character before anything changes. All of it happens on this device; 0 bytes of your text are uploaded.
Examples
When you paste text out of a PDF or an old email thread, every gap between words can arrive doubled, and a paragraph that looked perfectly clean in the source file suddenly reads ragged in your own editor.When you paste text out of a PDF or an old email thread, every gap between words can arrive doubled, and a paragraph that looked perfectly clean in the source file suddenly reads ragged in your own editor.Each widened gap is one run, so the counter reports 37 runs collapsed — a run being two or more spaces or tabs in a row. Single spaces and lone tabs pass through untouched.
function total(items) {
let n = 0; // counter
for (const item of items) {
n += item.price;
}
return n;
}function total(items) {
let n = 0; // counter
for (const item of items) {
n += item.price;
}
return n;
}Tab stops are columns, not character counts: every indentation tab here expands to four spaces, but the tab after the semicolon sits at column 14 and becomes just two to reach the next stop — expand(1) semantics, applied per line.
sku,product name,list price,in stock
8101,Walnut Roll Top Desk,839.00,yes
8102,Brass Desk Pen Holder,24.50,no
8103,Linen Desk Cable Wrap,12.90,yessku,product name,list price,in stock
8101,Walnut Roll Top Desk,839.00,yes
8102,Brass Desk Pen Holder,24.50,no
8103,Linen Desk Cable Wrap,12.90,yesA spreadsheet paste that reads like plain text: all 12 gaps are U+00A0 non-breaking spaces, which is why a CSV parser choked on them. Normalize exotic spaces rewrites each as a regular space.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
The ideographic space U+3000 is protected
Japanese text uses U+3000 as its full-width space, so normalize exotic spaces leaves it in place and posts a note instead. Converting it is a separate opt-in — CJK spacing is never rewritten silently.
Indentation that carries meaning
Input that looks like YAML or Python — consistent leading indents plus a colon-ended or def/class/if line — raises a warning chip when trim, collapse, tab conversion or remove-all is on. It never blocks; it names the risky ops.
CRLF stays CRLF
Line endings are preserved per line through every operation: a Windows file keeps \r\n, a mixed file stays mixed, and the status line reports what was detected. Nothing is quietly converted to LF.
A leading BOM is stripped and noted
Files saved by some Windows editors begin with U+FEFF. Strip zero-width characters removes it and posts a note naming the byte order mark — an invisible first character neither survives the cleanup nor vanishes without a trace.
Emoji survive by default
Family and flag emoji are glued together by zero-width joiners. The default strip protects U+200D, so sequences pass through byte-identical; only the advanced toggle removes joiners, and it counts every one it takes.
Common errors
Input is larger than the 8 MB limit for this tool.- A refusal, never a truncation: the cap exists so multi-megabyte minified files still clean, and past 8 MB the CLI line below does the same collapse at any size.
input looks indentation-structured (YAML/Python) — collapse runs can change indentation that carries meaning- Collapsing runs turns an eight-space indent into one space, which changes what a YAML mapping or Python block means. The chip is advisory: the run still happens, and it lists exactly the ops you enabled.
3 zero-width joiners removed inside emoji sequences — affected emoji will render as separate characters- A family emoji is several people joined by U+200D, so stripping the joiners makes 👨👩👧👦 fall apart into four faces. This only fires under the advanced toggle, and the count keeps the change honest.
FAQ
Why do these two strings look identical?
Because the difference is invisible: one carries a non-breaking space (U+00A0) or a zero-width character where the other has a plain space. The invisibles overlay gives every hidden code point a glyph with its Unicode name — the two strings stop looking identical.
Will this break my emoji?
No. The zero-width joiner (U+200D) holding family and flag emoji together is protected by default, so sequences come out byte-identical. Only the advanced “also inside emoji” toggle removes joiners, and it warns with a count.
Does it change my line endings (CRLF)?
Not by itself: endings are kept per line through every cleanup, so Windows files come out CRLF and mixed files stay mixed. Terminators disappear only with remove empty lines — for the dropped lines — or remove all whitespace.
Which option removes non-breaking spaces?
Normalize exotic spaces: it rewrites U+00A0 and the thin, hair, en and em space family into regular spaces, so runs collapse and trailing blanks trim in the same pass. The one exception is the ideographic space U+3000, which stays a separate opt-in.
In what order do the cleanups run?
Always the fixed order of the checkbox stack: strip zero-width, normalize exotic spaces, convert tabs, trim line ends, collapse runs, remove empty lines, remove all whitespace. Normalizing first is deliberate: a non-breaking space must become a real space before its run can collapse.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Re-run the cleanup now, at any input size.
- ⌘/Ctrl + S
- Download the cleaned text as .txt (overrides the browser save dialog).
- ⌘/Ctrl + C
- With nothing selected, copy the entire output; a selection copies just itself.
- ⌘/Ctrl + Shift + C
- Copy the entire output even while a selection exists.
- t
- Advance to the next theme palette (single-key guards apply).
- ? or ⌘/Ctrl + /
- Open the shortcut help overlay.
- Esc
- Dismiss the topmost overlay without touching the input.