Text that has been copied from a PDF, a web page, an email or a spreadsheet is rarely tidy. It arrives with double spaces after full stops, tabs in the middle of sentences, spaces dangling at the end of lines and long runs of blank lines. A remove extra spaces tool fixes all of that in one pass, so the text you paste into a document, a form or a database looks the way you meant it to.
What the remove extra spaces tool does
Paste your text into the box, choose the options you want and press the button. The tool works through the text line by line. With the first option on, every run of spaces and tabs inside a line becomes a single space. With the second option on, any space left at the very start or end of a line is trimmed. Then the blank line setting decides what happens to empty lines: keep them, reduce several in a row to one, or remove them all. The cleaned text appears in the result box with a Copy button, and a short line underneath tells you how many characters there were before and after.
Which characters count as a space
Not every gap in a text is the plain space you get from the space bar. Unicode defines a whole list of characters with the White_Space property, and the Wikipedia article on whitespace characters says the table lists "the twenty-five characters defined as whitespace" in the Unicode Character Database. [1] Among them are the ordinary space, the tab, the no-break space (U+00A0), which is described there as identical to a normal space but not a point at which a line may be broken, and the ideographic space (U+3000), which is as wide as a CJK character cell. [1]
This tool collapses the characters you are most likely to meet when copying text: the ordinary space, the tab, the no-break space, the ogham space mark, the en and em spaces and their relatives (U+2000 to U+200A), the narrow no-break space, the medium mathematical space and the ideographic space. Each run of them becomes one ordinary space. That matters when text copied from a web page carries hidden no-break spaces: a normal find-and-replace for two spaces would miss them, but this tool does not.
Zero-width characters are not spaces
One thing the tool deliberately leaves alone is the zero-width space (U+200B). It is invisible, but it is not listed among the characters with the White_Space property; the same article puts it in a separate table of related characters where White_Space is no. [1] Removing it would change how some scripts are broken into lines, so it stays in your text. If you suspect hidden zero-width characters, a character counter will show a higher total than you can see on screen.
Line breaks and the blank line setting
Computers do not agree on how to end a line. Unix, Linux and macOS use a line feed, Windows uses a carriage return followed by a line feed, and classic Mac OS used a carriage return alone. [2] Unicode adds the line separator (U+2028), the paragraph separator (U+2029) and the next line character (U+0085). [2] The tool recognises all of these as the end of a line, so text from any source is split correctly. The cleaned text always uses a plain line feed between lines, which every modern editor, browser and spreadsheet understands.
The blank line setting has three choices. Keep leaves your empty lines exactly as they were, which is right when the gaps between paragraphs are meaningful. Reduce turns two or more empty lines in a row into one, which is the usual choice for tidying an email or an article. Remove deletes every empty line and gives you a compact block, handy for lists, code snippets and data you are about to paste into a spreadsheet.
Common uses
- Cleaning text copied out of a PDF, where lines often end with spaces and words are separated by several spaces.
- Preparing a list of names, emails or product codes before you paste it into a spreadsheet or a mailing tool.
- Fixing the double space some people type after a full stop before text goes into a layout program.
- Stripping the stray tabs that come with text exported from a table or an old document.
- Tidying a draft before you count the words or check a character limit.
Step by step
- Paste or type your text into the box.
- Leave the first two options on for a full clean, or switch one off if you want to keep, for example, the spacing inside lines.
- Pick how blank lines should be handled.
- Press Clean text and read the result.
- Press Copy result and paste the cleaned text where you need it.
A worked example
Suppose you paste the text " Dear Sam,", then an empty line, then another empty line, then "Thanks for the quick reply. ". With the default settings, the first line loses its two leading spaces and the three spaces inside it shrink to one. The second line loses its trailing spaces and its internal runs of spaces. The two empty lines in a row become a single empty line. The result is three tidy lines of text with exactly one blank line between the greeting and the message.
Limits and good habits
The tool works on up to two million characters at a time, which is far more than most documents contain. Everything happens in your browser, so nothing you paste is uploaded or stored. Keep a copy of the original if the spacing carries meaning, for example in poetry, source code or a table laid out with spaces, because collapsing spaces cannot be undone. For code, switch off the collapse option and use only the trim and blank line settings, or leave the text alone.
What next
Use this often? Add Remove Extra to your Home screen.
Frequently asked questions
How does the remove extra spaces tool work?
It reads your text line by line, turns each run of spaces and tabs into one space, trims the start and end of every line and then applies your blank line choice. The result appears in the box below and can be copied.
Will it remove spaces between words completely?
No. It keeps one space between words. Only repeated spaces, tabs and similar gap characters are reduced to a single space.
Does it handle no-break spaces and tabs?
Yes. The no-break space, tab, en and em spaces, the narrow no-break space and the ideographic space all count as spaces and are collapsed to one ordinary space.
Can I keep my paragraph breaks?
Yes. Set blank lines to reduce several to one, or keep them as they are. Choose remove only if you want a solid block of text.
Is my text uploaded anywhere?
No. The cleaning runs in your browser and nothing you type or paste is sent to a server.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.