Remove Extra Spaces

Clean up text pasted from PDFs, websites, emails and spreadsheets: collapse double spaces, trim every line, tidy blank lines and remove hidden characters, with a report of what changed.

100% freeNo sign-upRuns in your browserWorks on mobile
Blank lines
0Extra spaces removed
0Tabs converted
0Odd spaces replaced
0Invisible characters removed
0Blank lines removed
0Spaces before punctuation

How to use the Remove Extra Spaces

  1. Paste your text into the left box.
  2. Leave the recommended options on, or untick any you want to keep, such as tabs in spreadsheet data.
  3. Choose how to handle blank lines: keep them, allow at most one in a row, or remove them all.
  4. Check the counts to see exactly what was cleaned, then copy or download the result.

Features

  • Collapses double and triple spaces into single spaces
  • Trims spaces and tabs from the start and end of every line
  • Replaces non-breaking, thin and other unusual spaces with normal ones
  • Removes zero-width spaces, byte order marks and soft hyphens
  • Keeps characters that emoji and some languages need, such as zero-width joiners
  • Reports how many of each problem it fixed

Where extra whitespace comes from

Text rarely arrives clean. PDFs add spaces to justify lines, web pages use non-breaking spaces to stop words wrapping, older typing habits put two spaces after every full stop, spreadsheets pad cells with trailing spaces, and copying from chat apps or code editors brings tabs along. Most of these are harmless on screen but cause real problems later: a search for “New York” misses “New York”, a spreadsheet lookup fails because one cell ends with a space, or a password pasted from an email will not work.

What each option removes

CharacterCodeWhy it causes trouble
Repeated spacesU+0020Uneven gaps, broken alignment, failed matching
TabU+0009Displays at different widths in every app
No-break spaceU+00A0Looks like a space but fails searches and spreadsheet comparisons
Narrow no-break, thin and em spacesU+202F, U+2009, U+2003…Typographic spaces that confuse plain-text tools
Zero-width spaceU+200BCompletely invisible; breaks URLs, code and logins
Byte order markU+FEFFHidden at the start of files; corrupts CSV headers
Soft hyphenU+00ADInvisible until a word wraps, then a stray hyphen appears

Collapse repeated spaces only shrinks runs that follow text, so indentation at the start of a line is preserved when trimming is switched off. Trim removes spaces and tabs from both ends of every line. Remove spaces before punctuation fixes “Hello , world !” style typos; leave it off for French text, which puts a space before some punctuation marks on purpose.

What is deliberately left alone

Some invisible characters do important work. The zero-width joiner (U+200D) glues emoji together, so 👨‍👩‍👧 is one family rather than three separate people, and it also shapes letters in scripts such as Devanagari and Malayalam. The zero-width non-joiner (U+200C) controls letter joining in Persian and other languages. Direction marks keep Arabic, Hebrew and Urdu text displaying correctly. Removing any of these would damage text rather than clean it, so this tool keeps them.

One space or two after a full stop?

Two spaces after a sentence was a typewriter convention, when every letter had the same width. Modern style guides, including the Chicago Manual of Style and the seventh edition of the APA Publication Manual, recommend a single space. Collapsing repeated spaces converts old documents to that style automatically.

Tips for spreadsheets and data

  • Excel’s TRIM function removes ordinary spaces but not non-breaking spaces (character 160), which is why some cells refuse to match. Cleaning the column here first fixes that.
  • If your data is tab-separated, untick Turn tabs into spaces so the columns survive.
  • After cleaning a list, remove repeated entries with Remove Duplicate Lines.
  • For text broken into short lines, such as a PDF copy, use Remove Line Breaks next.

Frequently asked questions

The cleaned text looks the same. Did anything change?

Probably, if the counters are above zero. Non-breaking spaces and zero-width characters look identical to normal spaces or to nothing at all, which is exactly why they cause problems.

Will this break emoji or non-English text?

No. The zero-width joiner and non-joiner, which emoji and several writing systems depend on, are kept, along with direction marks for right-to-left languages.

What is a non-breaking space?

A space character (U+00A0) that stops a line from wrapping between two words. Web pages use it a lot, and it often comes along when you copy text from a browser.

Can I keep tabs in tab-separated data?

Yes. Untick “Turn tabs into spaces” and tabs are left exactly where they are. Repeated-space collapsing only affects normal spaces.

Is my text uploaded?

No. All cleaning happens in your browser and the text never leaves your device.

More text tools

Other free tools you might need next.

View all 20