Skip to contentSkip to the inputSkip to the result

Clean spaces & blank lines

Remove excessive spacing from pasted text.

Loading tool

Instructions

Clean spaces & blank lines

How to use

  1. Tick the clean-ups you need; several run together in a fixed order.

Supported input

  • Collapse runs of blank lines to keep paragraphs, or remove every blank line.

Input example

 Hello   world

Result example

Hello world

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • Remove excessive spacing from pasted text.

Stray spaces in copied text, and the order they are cleaned in

Where the extra spaces come from

  • Web pages: non-breaking spaces (U+00A0, the HTML  ) that look like ordinary spaces, and invisible zero-width spaces (U+200B) left by editors.
  • Chinese, Japanese and Korean documents: the full-width ideographic space (U+3000) used for indents and alignment.
  • Files saved as UTF-8 by Windows Notepad: a byte order mark (U+FEFF) at the start and CR LF line endings.
  • Code editors and spreadsheets: indentation tabs, spaces left at line ends, tabs between cells.

Invisible characters always go

Whatever you tick, zero-width spaces (U+200B), word joiners (U+2060) and byte order marks (U+FEFF) are removed first, and carriage returns are dropped so every line ends in a single LF. None of them shows on screen, but each one makes find, compare and duplicate checks treat identical-looking text as different.

Despite its name, U+200B is not in Unicode’s White_Space property, so ordinary whitespace rules never catch it; that is why it is removed separately. Non-breaking and ideographic spaces are White_Space characters, and the collapse step shrinks them like any other space.

One fixed order

The order you tick boxes in does not matter. What matters is that each step feeds the next: a line of spaces only counts as blank after the collapse step has emptied it, and converting tabs alone leaves an indent of four spaces, which the collapse step then removes.

  1. 1Tabs and wide spaces: each tab becomes four spaces; ideographic and non-breaking spaces become one space.
  2. 2Line ends: spaces at the end of each line go, indentation stays.
  3. 3Runs of spaces: each line is trimmed and every run of spaces inside it becomes one; a line holding only spaces becomes empty.
  4. 4Squeeze blank lines: a run of blank lines becomes one.
  5. 5Remove blank lines: every blank line goes.

Worked example: a paragraph copied from the web

Take a text with a byte order mark at the start, a heading followed by a zero-width space and three spaces, a line indented with a tab that contains an ideographic space and a non-breaking space, three blank lines, a second paragraph with three spaces inside and a tab at the end, a line of three spaces, and a last word.

  • Line ends only: the invisible characters and carriage returns go, but the inner spaces, the indent tab and all three blank lines stay.
  • Runs of spaces: every line gets single spacing and loses its indent, but the three blank lines are still there.
  • Runs of spaces plus squeeze: six lines, with one blank line between paragraphs.
  • Runs of spaces plus remove blank lines: four lines and no gaps.

Text that cleaning breaks

  • Markdown uses two spaces at the end of a line as a hard line break. Removing line-end spaces joins that line to the next.
  • In Python and YAML the indentation is syntax. Collapsing spaces strips it, so use Line ends only on those files.
  • Makefile recipe lines must begin with a tab; converted to spaces, make stops with a “missing separator” error.
  • A tab always becomes exactly four spaces, not the space to the next tab stop, so columns lined up with tabs can drift.

Checked

Frequently asked questions

How do I collapse repeated spaces into one?

The default mode trims each line and turns runs of spaces and tabs into a single space. Non-breaking spaces copied from web pages are included. Blank lines stay, so paragraphs are kept.

Can I remove trailing spaces but keep indentation?

Yes. Choose Trailing spaces only. Indentation and spacing inside lines stay as they are, which suits code or aligned tables.

What happens to tabs and full-width spaces?

With Tabs and wide spaces to spaces, each tab becomes four spaces and each full-width space (U+3000) becomes one normal space. Line breaks in the result are LF.