Remove Extra Spaces
Clean up your text by removing extra spaces, tabs, and trailing whitespace while keeping single spaces between words.
Related Tools
How to Use
- Paste Your Text — Paste text that contains extra spaces, tabs, non-breaking spaces, or irregular whitespace into the input field.
- Select Cleanup Options — Tick the cleanups you want: collapse multiple spaces, convert tabs to spaces, convert non-breaking and other Unicode spaces, trim spaces at line starts (untick to keep indentation), and trim spaces at line ends.
- Copy Clean Text — Click Clean Spaces to replace your text with the normalized result, then copy or download it. Undo restores the original if needed.
About Remove Extra Spaces
Remove Extra Spaces fixes horizontal whitespace without touching your line breaks. With the default options it collapses runs of spaces into one, turns tabs and non-breaking or other Unicode spaces into ordinary spaces, and trims the start and end of every line. Use it on text pasted from PDFs, web pages, Word documents and emails, and on spreadsheet or CSV values where a stray space makes "Smith" and "Smith " look like two different entries.
What each option does
Each option has its own checkbox, and they are applied to every line in this order:
- Convert non-breaking & other Unicode spaces replaces each one with a regular space: the no-break space (U+00A0), narrow no-break space (U+202F), the en, em, thin and hair spaces (U+2000–U+200A), the ideographic space (U+3000) and similar characters, plus stray byte-order marks (U+FEFF), form feeds and vertical tabs.
- Convert tabs to spaces turns each tab into a single space. Tabs are not expanded to tab stops.
- Collapse multiple spaces into one reduces every run of two or more spaces to one.
- Trim spaces at line starts removes indentation. Untick it to keep each line's indentation exactly as it was, tabs included, while the rest of the line is still cleaned.
- Trim spaces at line ends removes trailing whitespace and empties lines that contain nothing but whitespace.
The live counters show multi-space runs, tabs, Unicode spaces and how many characters will be removed. Clicking Clean Spaces replaces your text, and Undo restores it.
Worked examples
In this table, ␣ stands for a space, → for a tab and [NBSP] for a non-breaking space.
| Input | Options | Output |
|---|---|---|
␣␣Hello␣␣␣␣world.␣␣ | Defaults | Hello␣world. |
Second→line→→here␣␣ | Defaults | Second␣line␣here |
Price:[NBSP]100[NBSP]USD | Defaults | Price:␣100␣USD (2 spaces converted, none removed) |
␣␣␣␣return␣␣1;␣␣␣ | Trim line starts off | ␣␣␣␣return␣1; |
a→→b | Collapse off | a␣␣b |
a→→b␣␣c | Convert tabs off | a→→b␣c |
What it leaves alone
- Line breaks and blank lines stay where they are, although Windows (CRLF) line endings come out as LF. To join lines, use Remove Line Breaks; to drop blank lines, use Remove Empty Lines.
- Single spaces are never removed, including a space before punctuation: "Hello ." stays "Hello .".
- Zero-width characters, such as the zero-width space (U+200B), the zero-width joiners (U+200C, U+200D) and the word joiner (U+2060), are not whitespace and stay in place. The Invisible Character Detector shows and removes them.
- One exception to "line breaks are untouched": the rare Unicode line separator (U+2028) and paragraph separator (U+2029) count as Unicode spaces and become ordinary spaces.
- In source code, collapsing also squeezes spaces inside strings and alignment padding; untick Collapse when that matters.
When to use it
Clean text copied from PDFs and justified layouts, which often arrives with doubled spaces. Strip the non-breaking spaces that web pages produce from : they look normal but break searches, find-and-replace and spreadsheet lookups. Reduce the two spaces some writers still type after a period to one. Before importing a list into a spreadsheet or database, trim line ends so that "Smith" and "Smith " are not stored as two values. The guide How to Remove Extra Spaces and Fix Text Spacing explains the different whitespace characters in more depth.
Cleaning runs in your browser; your text never leaves your device.
Frequently Asked Questions
What counts as "extra" spaces?
With the default options, any sequence of two or more consecutive space characters is reduced to a single space, spaces at the beginning and end of each line are removed, and tabs, non-breaking spaces, and other Unicode space characters are converted to regular spaces. Each of these steps has its own checkbox, so you can switch off any you do not want.
Does the tool remove tabs as well as spaces?
Yes, by default. Each tab character is converted to a space, and the resulting runs of spaces are collapsed into one. If you need to preserve tab-separated formatting, untick "Convert tabs to spaces" and the tool will only collapse runs of regular spaces, leaving tabs between words intact. Tabs at the very start or end of a line are still removed while the two trim options are ticked.
Will it remove line breaks or paragraph spacing?
No. This tool focuses exclusively on horizontal whitespace (spaces and tabs). Line breaks and paragraph separations are preserved. To remove line breaks, use the dedicated Remove Line Breaks tool.
Why does my text have extra spaces in the first place?
Extra spaces commonly appear when copying text from PDFs, web pages, Word documents, or email clients. Different applications handle whitespace differently during copy-paste operations, often inserting additional spaces or converting formatting to multiple spaces.
Can I clean up spaces in code without breaking indentation?
Yes. Untick "Trim spaces at line starts" and the leading indentation of every line (spaces or tabs) is kept exactly as it is, while trailing whitespace is still removed and runs of spaces after the indentation are still reduced. This is useful for cleaning up source code where indentation is semantically meaningful.