How to remove extra spaces from text
- Paste the text you want to clean into the Input box.
- Keep the five clean-up options on, or untick the ones you do not want: Normalise special spaces, Tabs to spaces, Collapse spaces, Trim lines and Remove empty lines.
- Check the Output box. It updates as you type, and the counters show the character, word and line counts before and after.
- Copy the cleaned text, or download it as a .txt file.
Why use this tool
Spreadsheet values that will not match
A trailing space is invisible but real: lookups such as VLOOKUP or XLOOKUP and exact-match filters treat "Acme " and "Acme" as different values, and a non-breaking space copied from a web page looks exactly like a normal one. Paste a column of names or codes here, clean it with the default options, and paste the column back.
Two spaces after a full stop
Many people learned to type two spaces after each sentence. Most current style guides, including the Chicago Manual of Style and the AP Stylebook, call for one. Collapse spaces fixes a whole manuscript at once without touching the single spaces between words.
Text from PDFs, OCR and web pages
Copied text often brings runs of spaces used for alignment, tabs from table columns, non-breaking spaces from HTML and stray blank lines. One pass turns it into plain, evenly spaced text that is ready to edit.
Lists before an import
Email addresses, tags or keywords gathered from several sources end up with blank lines and uneven spacing. Clean them first so the import does not create empty rows or near-duplicate entries.
Private by design
The text you paste or type is processed in this browser tab. It is never uploaded or stored, so you can clean up internal documents or customer data without it leaving your device. No account needed.
Good to know
What each option does
- Normalise special spaces: characters that look like a space but are not the ordinary one become an ordinary space. That covers the non-breaking space (U+00A0, common in text from web pages and Word), the narrow no-break space (U+202F, used in some time and number formats), the thin, en and em spaces, the ideographic space (U+3000) and the other Unicode space characters. Invisible characters that only break matching are deleted: the zero-width space (U+200B), the word joiner (U+2060) and the byte order mark (U+FEFF). Zero-width joiners are kept, because emoji and several scripts depend on them.
- Tabs to spaces: each tab becomes one space. With Collapse spaces on, a run of tabs ends up as a single space.
- Collapse spaces: any run of two or more spaces becomes one ordinary space. Special spaces count as spaces here even with Normalise off, so a mixed run also becomes one space.
- Trim lines: removes spaces, tabs, special spaces and zero-width spaces at the start and end of every line.
- Remove empty lines: deletes lines that are empty or hold only whitespace or zero-width characters.
The options run in that order, and line endings are normalised to LF. Single line breaks are always kept. To join lines into paragraphs, use Remove Line Breaks.
Careful with code. Trim lines strips indentation, and indentation carries meaning in Python, YAML and Makefiles. Collapse spaces can also change spacing inside string literals. For source code, use a formatter for that language instead.
In — Messy address block with tabs
Order #4471
Ship to: Jane Doe
12 Harbour RoadOut — All options on
Order #4471
Ship to: Jane Doe
12 Harbour RoadFrequently asked questions
Will it remove the single spaces between my words?
No. Only runs of two or more spaces are collapsed, and they become exactly one space. A single space between words is never removed, and neither is a single line break. A lone special space, such as a non-breaking one, is replaced by an ordinary space; only invisible zero-width characters are deleted outright.
Why does Excel TRIM not remove all the spaces?
Excel TRIM removes only the regular space character (code 32). Text copied from web pages often contains non-breaking spaces (code 160), which TRIM leaves in place. You can wrap the cell in SUBSTITUTE(A1, CHAR(160), " ") first, or paste the column here: Normalise special spaces turns every non-breaking space into a regular one, then Collapse spaces and Trim lines do what TRIM does.
What is a non-breaking space?
A character (U+00A0) that looks like a space but stops a line from wrapping at that point. HTML writes it as , and Word and many websites insert it automatically. A normal find-and-replace on " " misses it, which is why doubled spaces sometimes seem impossible to remove.
Does it keep my paragraphs?
Line breaks are kept, so lines and paragraphs stay where they are. Remove empty lines does delete the blank lines between paragraphs; untick it if you want those gaps to stay.
Can I use it on source code?
Only with care. Trim lines and Tabs to spaces destroy indentation, and Collapse spaces and Normalise special spaces can change string literals and aligned comments. For code, a language-specific formatter is the right tool.