Page & Bell

Whitespace Cleaner

Paste any text and this whitespace cleaner collapses double spaces, trims line ends, converts tabs, and replaces invisible Unicode spaces (NBSP, thin space, full-width CJK space) with normal ones — then tells you exactly how many of each it removed. Everything runs in your browser; nothing is uploaded.

Options

Output appears here as soon as you paste something.

How to use the whitespace cleaner

  1. Paste your text into the box — cleaning happens live as you type.
  2. Tick the options you need: collapse space runs, trim line ends, tab handling, Unicode space conversion, blank-line removal.
  3. Turn on “Preserve indentation” if you are cleaning code or poetry where leading spaces matter.
  4. Read the stats line to see what was removed, then hit Copy result.

Why invisible whitespace causes real bugs

The classic failure is the spreadsheet key match. You export customer names from one system and paste a lookup list from another. One list has "Johnson " with a trailing NBSP copied from a web page; the other has plain "Johnson". VLOOKUP returns #N/A for that row and every row like it, dedupe keeps both, and a mail merge sends two emails to the same person. The strings are byte-different but pixel-identical — no amount of staring at the screen will find it. Running both columns through this cleaner with “Convert NBSP & Unicode spaces” and “Trim start/end of every line” enabled normalises the keys in one paste.

PDFs are the other repeat offender. Extracted text frequently contains runs of three to ten spaces where the original layout had a column gap, plus stray tabs. The stats line makes the damage visible: a typical two-page PDF paste reports something like “142 extra spaces, 18 tabs, 9 non-breaking/Unicode spaces removed”.

What each option does, precisely

  • Collapse runs of spaces — any sequence of two or more spaces becomes one. A run of 5 spaces counts as 4 removed.
  • Trim start/end of every line — strips leading and trailing spaces and tabs per line. Trailing whitespace is the most common invisible diff noise in version control.
  • Tabs — convert each tab to a single space, remove it entirely, or keep it. Keep tabs when the text is tab-separated data you plan to paste into a spreadsheet.
  • Remove blank lines — drops lines that are empty after cleaning. Useful before pasting lists into tools that treat every line as an item.

If your problem is line breaks rather than spaces — hard-wrapped email text, PDF paragraphs broken mid-sentence — use the dedicated Line Break Remover, which understands paragraph boundaries. For a one-click everything pass (HTML tags, smart quotes, spaces, breaks), the Text Cleaner combines both.

Frequently asked questions

Where do double spaces and weird invisible spaces come from?

Three main sources: Microsoft Word (the old two-spaces-after-a-period habit, plus non-breaking spaces it inserts automatically before units and after certain words in some locales), copy-paste from web pages (HTML collapses whitespace visually but the clipboard keeps every non-breaking-space entity as U+00A0), and PDFs (text extraction often inserts runs of spaces to fake column alignment). They all look identical on screen, which is why a cleaner that reports counts is more trustworthy than eyeballing.

What is an NBSP and why does it break spreadsheets?

NBSP is the non-breaking space, Unicode U+00A0. To Excel, Google Sheets, and SQL, “Dallas” with a trailing NBSP and plain “Dallas” are different strings, so VLOOKUP and MATCH return errors, Remove Duplicates misses rows, and joins silently drop records. TRIM() in Excel does not strip NBSP either — it only handles the regular space U+0020. Converting NBSP to a normal space before import fixes all of these at once.

Which Unicode space characters does the tool convert?

U+00A0 (no-break space), the U+2000–U+200A block (en quad, em quad, en space, em space, three-per-em, four-per-em, six-per-em, figure, punctuation, thin and hair spaces), U+202F (narrow no-break space, common in French number formatting), and U+3000 (ideographic full-width space used in Chinese and Japanese text). Each one is counted and replaced with a regular U+0020 space.

Will it destroy the indentation in my code?

Not if you enable “Preserve indentation”. In that mode the cleaner leaves leading spaces and tabs untouched on every line and only trims trailing whitespace and collapses internal space runs. Leave it off for normal prose, where leading spaces are almost always paste artefacts.

What does “Remove ALL spaces” do, and when would I use it?

It deletes every space character instead of collapsing runs, which is useful for things that must contain no spaces at all: coupon codes, IBAN or card numbers pasted with grouping spaces, hex colour lists, or URLs broken across a PDF line. It overrides the collapse option while active — the two are mutually exclusive by design.

Is there a size limit?

The cleaner processes text line by line with simple replacements, so even multi-megabyte pastes (full book manuscripts, large CSV exports) clean in well under a second on a typical laptop. An empty input simply shows nothing — there is no error state to deal with.

Related tools

Learn more