Text

Whitespace and Blank Line Cleaner

Strips trailing whitespace, collapses runs of spaces, converts tabs and tidies blank lines.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the text you want cleaned.
  2. Leave trailing space removal on — it is the fix that solves most invisible problems.
  3. Turn on tab conversion, space collapsing or blank line handling only if you actually want them; each one changes the text visibly.
  4. Select Clean. If two values still will not compare equal afterwards, run them through the character frequency counter to find what is really in them.

What whitespace cleaner does

Trailing whitespace is invisible and expensive. It shows up as a diff on a line nobody edited, it breaks an equality check between two strings that look identical, and it turns a lookup key into a value that matches nothing. Stripping it is the single most useful thing on this page, and it is on by default.

The rest is layout: tabs converted to a fixed number of spaces, runs of spaces collapsed to one, leading indentation removed, and blank lines either collapsed to a single blank or removed entirely. Non-breaking spaces are deliberately left alone. A non-breaking space is a character somebody chose, not stray whitespace, and silently deleting it would change the text.

Frequently asked questions

Because it is invisible and changes behaviour. It makes a version control diff appear on a line nobody edited, it makes two strings that look identical compare as different, and it turns a lookup key into one that matches nothing. It is the default fix on this page for that reason.

No, deliberately. A non-breaking space is a character somebody chose — usually to hold a number and its unit together — not stray whitespace. Removing it silently would change the text. If you need to find them, the character frequency counter lists them as U+00A0.

Collapsing turns any run of consecutive blank lines into a single one, which keeps the paragraph structure while removing the gaps. Removing takes out every blank line, which is what you want for a list and what you almost never want for prose.