devtools

Whitespace Cleaner

Clean messy whitespace online: collapse repeated spaces, trim lines, remove blank lines, expand tabs, and strip non-breaking spaces. Private, in-browser.

Runs entirely in your browser — your data never leaves your device.

How to use Whitespace Cleaner

What it does & when you need it

Text you copy from a PDF, an email, a spreadsheet, or a chat window arrives full of invisible mess: double spaces, stray tabs, trailing whitespace, blank lines between every paragraph, and non-breaking spaces that look ordinary but behave differently. This tool cleans all of that up in one pass. You choose which rules to apply — collapse runs of spaces, trim each line, drop blank lines, expand tabs, strip the document's leading and trailing whitespace, or remove every whitespace character entirely — and the result updates as you type.

It runs entirely in your browser, so pasted contracts, log excerpts, or private notes never leave your machine. Reach for it before committing a config file, tidying data copied out of a table, or normalising a block of prose so a diff shows only the changes that matter.

How to use

  1. Paste your text into the input buffer, press Sample to load a messy example, or Upload a .txt, .md, or .log file.
  2. Toggle the rules you want: Collapse spaces, Trim lines, Remove blank lines, Trim ends, a Tabs conversion width, or Strip all to remove every whitespace character.
  3. Read the result in the cleaned buffer — the status bar shows how many characters were removed. Press Copy result or Ctrl/Cmd + Enter to grab it.

Things worth knowing

Collapsing handles Unicode spaces, not just the ordinary one. A non-breaking space (U+00A0), the narrow no-break space, and the en and em spaces all look like a normal gap but are different code points, and they routinely sneak in from word processors and web pages. The collapse rule folds any run of horizontal whitespace — including those — down to a single ordinary space, while leaving your line breaks alone.

Order is deliberate. Tabs are expanded first, then spaces are collapsed, then lines are trimmed and blank lines removed, and finally the whole document is trimmed. That sequence means a line of only spaces becomes genuinely empty and is caught by blank-line removal. Strip all overrides everything, deleting every space, tab, and newline at once.

Once the text is clean you might count what is left, sort the lines, or diff two versions.

Examples

Collapse repeated spaces

This   sentence   has   far   too   many   spaces.

With Collapse spaces on, every run of spaces folds down to a single space.

Trailing spaces and blank lines

First line.   


Second line.   

Trim lines strips the trailing spaces and Remove blank lines drops the empty rows between them.

Tabs to spaces

name	age	city

Set the Tabs option to 2, 4, or 8 to expand each tab into that many spaces.

Frequently asked questions

How do I remove extra spaces between words?

Enable Collapse spaces. It folds any run of horizontal whitespace — ordinary spaces, tabs, and Unicode spaces like the non-breaking space — down to a single ordinary space, without touching your line breaks. So "too many spaces" becomes "too many spaces" in one pass.

Why do two spaces I cannot see refuse to collapse elsewhere?

They are probably not ordinary spaces. Text pasted from web pages and word processors often contains non-breaking spaces (U+00A0) or narrow no-break spaces that look identical but are different characters. Collapse spaces and Strip all both recognise the whole Unicode space-separator category, so those hidden characters are handled too.

In what order are the cleaning rules applied?

Tabs are expanded first, then spaces are collapsed, then each line is trimmed and blank lines are removed, and finally the whole document is trimmed. That sequence means a line containing only spaces becomes truly empty and is caught by Remove blank lines. Strip all overrides everything and deletes every whitespace character.

What is the difference between Trim lines and Trim ends?

Trim lines removes leading and trailing whitespace from every individual line, so indentation and trailing spaces on each row disappear. Trim ends only removes whitespace from the very start and very end of the whole text, including surrounding blank lines, while leaving the interior untouched.

Is my text uploaded anywhere?

No. All cleaning happens locally in your browser with no network request, so pasted configs, logs, or private notes never leave your machine. Once the page has loaded it also works offline.