Text cleaner

Collapses double spaces, trims line ends and removes repeated blank lines.

A quick tidy-up for text pasted from anywhere: extra spaces collapse to one, trailing spaces disappear and long runs of blank lines shrink to a single empty line.

Try:
0Words
0Characters
0No spaces
0Sentences
0Paragraphs
0Lines
0Pages
0Reading
0Speaking

Runs entirely in your browser. Your text is never uploaded — open DevTools, Network tab, and you will see zero requests while you use this tool.

How to use it

  1. Paste the text you want to tidy.
  2. Press Clean spacing.
  3. Copy the cleaned result.

What this tool does

Clean spacing normalises whitespace without touching a single word:

Two more buttons are on the same page because they are usually needed together: Join lines merges the text into one paragraph, and Remove duplicate lines strips repeated entries from a list.

Invisible characters that come from Word and the web

The visible mess is the easy part. The characters that cause real trouble are the ones you cannot see, and text pasted from Word, Google Docs, Outlook or a web page is full of them.

CharacterWhere it comes fromWhat breaks
Non-breaking space (U+00A0)Word autoformat, and   copied from a web pageLooks like a space but is not one. A search for two words separated by a normal space finds nothing, and TRIM in Excel does not remove it.
Curly quotes ‘ ’ “ ”Word and Docs autocorrect straight quotes as you typeBreaks code, CSV files, JSON and shell commands, which need straight ' and ".
En and em dashes – —Autocorrect turns -- into a dashWrong in identifiers, filenames and command lines.
Zero-width space (U+200B) and zero-width joinerCopied from web pages and CMS editorsInvisible, but consumes character-limit budget and defeats exact-match search.
Soft hyphen (U+00AD)Hyphenation in Word and in HTMLInvisible until the word wraps, then a hyphen appears out of nowhere.
Byte order mark (U+FEFF)The first character of many exported filesCorrupts the first column header of a CSV import.
Carriage return (\r)Windows line endings on a Unix systemShows as ^M, and makes string comparisons fail for no visible reason.

The pattern is always the same: two strings look identical on screen and refuse to match. Anywhere text is compared — a spreadsheet lookup, a database key, a find-and-replace, a deduplication — one invisible character makes the two values different. Cleaning whitespace first removes the most common source of that failure.

Examples

BeforeAfter Clean spacing
Hello    world  Hello world
   indented lineindented line
para one




para two
para one

para two
a b (tabs)a b

A typical sequence for text pasted out of an email thread: Clean spacing to fix the whitespace, Remove duplicate lines to drop repeated quoted replies, then check the counters to see how much shorter it became.

When you need it

Doing it without this tool

Privacy: your text never leaves your browser

Cleaning is a set of regular expressions applied locally by JavaScript. No upload, no server processing, no storage, no account. Reload the page and the box is empty again.

People clean text precisely because it came from somewhere sensitive — an internal document, a customer export, an email thread. Keeping the processing on your device means the cleanup does not itself become a data disclosure.

Related tools

Remove special charactersKeeps letters, numbers and spaces — everything else goes.Remove punctuationStrips punctuation and symbols, optionally keeping apostrophes and hyphens.Remove empty linesDeletes blank lines — or collapses runs of them down to one.Remove stop wordsStrips common English filler words and leaves the words that carry meaning.How random is randomGood enough for a raffle, not good enough for a password. Here is the actual…Meta description lengthWhy 160 characters is a rule of thumb and 920 pixels is the real limit.Fancy fonts show boxesThose styled letters are separate Unicode characters, not styling. That…

See all text tools →

Frequently asked questions

What exactly gets removed?

Runs of spaces and tabs collapse to a single space, whitespace at the start and end of each line is trimmed, and three or more blank lines become one.

Does it change my words?

No. Only whitespace is touched. Letters, punctuation, capitalisation and line order stay exactly as they were.

Why does text pasted from Word break my page?

Word inserts non-breaking spaces, curly quotes and em dashes automatically. They look normal but break code, CSV files and exact-match search.

What is a non-breaking space and why is it a problem?

It is a separate character (U+00A0) that renders like a space but never wraps. Search and TRIM in Excel do not treat it as whitespace, so identical-looking values fail to match.

Will it fix curly quotes?

Clean spacing only handles whitespace. To replace curly quotes, use find and replace in your editor, or turn off smart quotes in the AutoCorrect settings so they stop appearing.

How do I do the same in Excel?

Use =TRIM(A1) for ordinary spaces and =CLEAN(A1) for control characters. Non-breaking spaces need =TRIM(SUBSTITUTE(A1,CHAR(160)," ")).

Can I clean and count at once?

Yes. The counters under the box update after every action, so you can see immediately how much shorter the text became.