Remove Extra Spaces and Blank Lines

Quick answer: Clean up messy text in one step: collapse repeated spaces and tabs, trim the edges of every line, and tidy up empty lines.

Updated

Your text is processed entirely in this browser and is never sent to a server.

How to clean whitespace

  1. Paste the text with extra spaces, tabs or blank lines.
  2. Choose the options: collapse spaces, trim lines, and what to do with empty lines (keep, collapse to one, or remove all).
  3. Copy or download the cleaned text.

Examples

Default settings

Before

  Hello    world  



  Second   paragraph		

After

Hello world

Second paragraph
Remove all empty lines

Before

Apples

Pears


Plums

After

Apples
Pears
Plums
Collapse spaces, keep empty lines

Before

Name:     Ana   García

City:   Sevilla

After

Name: Ana García

City: Sevilla

When to use it

  • Fix text copied from PDFs, where lines are padded with spaces.
  • Tidy email replies and forwarded messages before quoting them.
  • Remove double spaces after periods in manuscripts and articles.
  • Prepare lists for spreadsheets, where stray spaces break matching.
  • Clean up content pasted from web pages into a CMS.

Details and limits

Collapsing spaces turns any run of normal spaces, tabs and non-breaking spaces into a single normal space. Because non-breaking spaces are replaced too, text pasted from web pages or word processors behaves like ordinary text afterwards. Trimming removes spaces and tabs at the start and end of every line, which also removes indentation, so turn it off for code or nested lists.

For empty lines, “collapse” leaves at most one blank line between paragraphs and “remove” deletes all of them. In both modes, empty lines at the very beginning and end of the text are dropped. A line that only contains spaces counts as empty once it has been trimmed. Windows (CRLF) line endings are converted to standard LF line breaks.

Zero-width characters such as the zero-width space (U+200B) are invisible but are not removed by this tool. If text still behaves strangely after cleaning, inspect it with the Unicode Normalizer to see every code point.

Frequently asked questions

Will this remove the line breaks in my paragraphs?

No. Line breaks inside paragraphs are kept. Only spaces and empty lines are cleaned, depending on the options you choose.

Can I keep indentation?

Yes. Turn off “trim lines” so spaces at the start of lines are kept. If “collapse spaces” is on, an indentation of several spaces still becomes one space, so turn that off as well for code.

What is a non-breaking space?

A space character (U+00A0) that prevents a line break between two words. It looks like a normal space but often breaks search, matching and formulas in spreadsheets.