Remove Extra Spaces

Collapse double spaces, tabs and non-breaking spaces into single spaces while keeping your line breaks. Optionally trim lines, reduce blank lines and fix spaces before punctuation.

Options

Processed in your browser. Nothing you type is uploaded.

How it works

Any run of two or more horizontal whitespace characters, and any single tab or special space such as a non-breaking or thin space, is replaced with one ordinary space. Line breaks are not touched, so your paragraphs stay where they are.

Rules this tool follows

  • Trim lines (default on) removes spaces at the start and end of every line, including indentation.
  • Reduce blank lines (default on) turns runs of blank lines into a single blank line.
  • Remove spaces before punctuation (default off) turns “word ,” into “word,”. It is off by default because French typography uses a space before ; : ! and ?.

Example

Input

This  sentence   has		strange    spacing.



   And this line starts with spaces.

Output

This sentence has strange spacing.

And this line starts with spaces.

Common uses

  • Cleaning text pasted from PDFs, emails and web pages.
  • Fixing double spaces after full stops.
  • Replacing non-breaking spaces that cause odd wrapping or failed searches.

Limitations and notes

  • Tabs are converted to spaces, which removes tab-aligned columns. For tab-separated data, use Trim Lines instead.
  • Code indentation is removed when trimming is on.

All text cleaners