Skip to content

Trim Whitespace and Extra Spaces

Clean up spaces in your text: trim the ends of every line, collapse repeated spaces, drop blank lines and fix non-breaking spaces.

Whitespace cleaner
Tick what to clean. The result updates at once.

Result
Cleaned text
Hello world

Tabbed line
last line
16
Characters removed
34
Characters left

Private: Everything runs in this page. Nothing you type is sent anywhere or saved.

On this page
  1. Whitespace examples
  2. Formula
  3. How the whitespace cleaner works
  4. What this tool does not do
  5. Frequently asked questions
  6. Related tools

Whitespace examples

Input (dots stand for spaces)Result
..a...b.."a b"
a....b"a b"
...a"a"
a\n\n\nb"a\nb"
..x..\n..y.."x\ny"

Formula

several spaces or tabs in a row become one space; spaces at line ends are cut

How the whitespace cleaner works

  1. Step onePaste your text into the box.
  2. Step twoTick the clean-up steps you want. The first three are on by default.
  3. Step threeCopy the cleaned text. The tiles show how many characters were removed.

What this tool does not do

  • It works on spaces, tabs and non-breaking spaces; it does not touch other invisible characters such as zero-width spaces.
  • It does not fix spelling or punctuation.
  • It does not change line breaks between Windows and Mac or Linux style.

Frequently asked questions

What is a non-breaking space?

A space (character 160) that looks like a normal one but stops a line from breaking there. It often comes from web pages and word processors, and it can break searches and imports.

Does it remove line breaks?

It keeps the lines. Tick the empty-line option to drop blank lines. To join lines into one, use find and replace on the line breaks.

Does it touch spaces inside words?

Only to collapse a run of spaces or tabs into one. A single space between words is never changed.