toolqik

156 · Text

Remove Extra Spaces

Collapse double spaces, trim lines and remove tabs, non-breaking and invisible spaces.

Runs in your browser
Clean up
Cleaned text

  

About this tool

Text copied from PDFs, websites, Word documents and spreadsheets is often full of double spaces, stray tabs, spaces at the start and end of lines, and characters you can’t even see. This tool cleans all of that in one go: repeated spaces become one, lines are trimmed, and unusual whitespace is normalized.

What gets cleaned

  • Double spaces: always collapsed to a single space.
  • Leading and trailing spaces on every line (trim).
  • Tabs, converted to single spaces.
  • Non-breaking and special spaces such as U+00A0 (from web pages and Word), thin spaces and ideographic spaces. They look like normal spaces but break searches, comparisons and spreadsheet formulas.
  • Zero-width characters (U+200B, U+FEFF and friends), which are invisible but make “identical” strings different, so a lookup or a password field may fail for no visible reason.
  • Optionally, runs of blank lines reduced to one, or all lines joined into a single line (handy for text copied from PDFs with hard line breaks).

The status line reports how many characters were cleaned. To remove empty lines only, use remove empty lines.

In code

// JavaScript: collapse whitespace and trim
text.replace(/[ \t\u00a0]+/g, ' ').trim();

# Python
" ".join(text.split())

FAQ

How do I remove double spaces from text?

Paste the text. Every run of spaces is collapsed to one and lines are trimmed automatically.

What are non-breaking spaces and why remove them?

U+00A0 looks like a normal space but is a different character. It often comes from web pages and Word, and it can make searches, comparisons and spreadsheet formulas fail.

What are zero-width characters?

Invisible characters such as U+200B (zero-width space) and U+FEFF (byte order mark). They don’t show on screen but make text differ, so they are removed.

Can I remove line breaks too?

Yes. “Join all lines into one” replaces line breaks with spaces, which fixes text copied from PDFs.

Does it change single spaces between words?

No. Single spaces stay; only extra or unusual whitespace is changed.

esc
↑↓ navigate↵ open