Clean up whitespace

Trim the edges of every line, collapse runs of spaces, drop empty lines and strip the invisible characters that break forms and code.

Clean up whitespace

0 characters

Three steps — nothing to install

  1. Paste the messy text

    Copied from a web page, a PDF, Word, or a spreadsheet cell with a stray tab.

  2. Tick the clean-ups

    Each one is separate, so you can see what changed and leave indentation alone when you need to.

  3. Copy the clean text

    The result appears immediately. Nothing is uploaded and nothing is stored.

The invisible characters that cause trouble

A non-breaking space looks like a space and is not one. It arrives from web pages, from Word, and from PDFs, and it breaks searches, comparisons and CSV parsing. A zero-width space looks like nothing at all and silently splits words. A byte-order mark at the start of a copied string makes the first word fail to match.

The clean-up replaces all of those with ordinary spaces or removes them, along with tabs and the rarer Unicode spaces. If a form says a field is empty when you can see text in it, one of these characters is usually the reason.

What each option does, in order

The clean-up runs in a fixed order: invisible characters become spaces, tabs become two spaces, each line is trimmed, runs of spaces collapse to one, and finally empty lines are removed if you asked for that. Doing it in this order means trimming can remove the spaces that tabs and invisible characters produced.

Leave trim the edges of every line off when you are cleaning code or a table with meaningful indentation. Collapsing runs of spaces is also unsafe inside code. For prose, both are usually what you want; for markup, use the HTML minifier instead, which knows what to leave alone.

Where the stray spaces come from

Double spaces after a full stop are a typing habit that survived from the typewriter era. They are harmless in HTML, which collapses them anyway, and visible in plain text, Markdown source and SMS. Trailing spaces are worse: they are invisible, they break line-based comparisons, and some version control systems flag them as errors.

Copying from Word brings its own set: curly quotes, non-breaking spaces and sometimes a trailing paragraph mark. If you are moving text into a database or a form, clean it here first and check the result in the word counter before submitting.

Frequently asked questions

Will it remove my indentation?Only if you tick Trim the edges of every line. Leave that off for code; the tab and space options still work.
What is a non-breaking space?A space that prevents a line break, common on web pages and in Word. It looks identical to a normal space and breaks searches, so it is replaced here.
Does it fix double spaces after full stops?Yes, when you collapse runs of spaces. That is a style choice, so it is a separate option rather than always on.
Can it remove zero-width characters?Yes. The invisible-character option removes zero-width spaces, joiners and the byte-order mark as well as non-breaking spaces.
Is the text uploaded?No. The replacements happen in this tab with regular expressions and no network request.
Does it change line breaks?Only if you remove empty lines. Otherwise the breaks stay where they were, with the line contents cleaned.