Text Cleaner

Remove extra spaces, line breaks and invisible characters.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.
Input

The Text Cleaner removes extra spaces, broken line breaks and invisible characters from text pasted out of Word, PDFs, email or chat. Turn cleanup operations on as chips, see exactly what was removed, and copy text that behaves in code, forms and spreadsheets. Everything runs in your browser — nothing is uploaded.

How to clean text and remove extra spaces

  1. Paste text into the input, or drop a .txt, .md or .csv file. Four chips are on by default: invisible characters, normalize spaces, collapse extra spaces and trim lines.
  2. Pick a preset — Clean for code, Fix PDF copy or Single line — or toggle individual chips. The output updates as you type, and the stats line reports what changed, for example "Removed 2 invisible characters, 5 extra spaces".
  3. Turn on highlighting to see removed characters underlined in the input, then copy the result or send it on to the Case Converter or the Line Ending Converter.

Examples

Messy text with hidden characters

This input contains a zero-width space after "Hello", a byte order mark at the very end, runs of spaces and trailing whitespace. Default chips plus Straighten quotes & dashes:

Text
Hello​ world,  this   text was copied from a PDF
and has hard
wrapped lines.   

“Smart quotes” and — dashes too.

Result:

Text
Hello world, this text was copied from a PDF
and has hard
wrapped lines.

"Smart quotes" and - dashes too.

Stats line: "Removed 2 invisible characters, 5 extra spaces, 1 leading/trailing space; replaced 3 quotes and dashes".

Text copied from a PDF

PDF viewers insert a line break at the end of every visual line. Fix line breaks joins lines inside a paragraph and keeps the blank line between paragraphs:

Text
The quick brown fox jumps over
the lazy dog. This paragraph was
copied from a PDF file.

A second paragraph follows
here.

Result:

Text
The quick brown fox jumps over the lazy dog. This paragraph was copied from a PDF file.

A second paragraph follows here.

A list pasted into one line

Remove all line breaks puts everything on a single line, separated by spaces — useful for search boxes and single-line form fields:

Text
Multi-line
search terms
copied from a list

Result:

Text
Multi-line search terms copied from a list

Options explained

Chips are applied in a fixed order, top to bottom, so the result never depends on the order you click them.

  • Remove invisible characters — deletes zero-width spaces, left-to-right and right-to-left marks, bidi controls, word joiners, soft hyphens, Unicode tag characters and the byte order mark (BOM). Zero-width joiners and non-joiners are removed too, except inside emoji sequences and next to non-Latin letters such as Persian or Devanagari, where they change how text renders; tag characters inside emoji flag sequences are kept.
  • Normalize spaces — turns non-breaking spaces (NBSP), narrow no-break spaces, em and en spaces and ideographic spaces into ordinary spaces.
  • Collapse extra spaces — replaces any run of two or more spaces or tabs with a single space.
  • Trim lines — removes leading and trailing spaces and tabs from every line.
  • Fix line breaks — joins hard-wrapped lines inside paragraphs, keeping blank-line paragraph breaks and leaving lines that start with a list marker, number, # or > on their own. A line that ends in a hyphen is joined without a space, and the hyphen is kept.
  • Remove all line breaks — joins everything onto one line; it overrides Fix line breaks.
  • Remove empty lines — deletes blank and whitespace-only lines.
  • Straighten quotes & dashes — turns curly quotes into straight quotes, en and em dashes into hyphens, and the ellipsis character into three dots.
  • Line endings — Preserve keeps CRLF if the input used it, otherwise LF; LF and CRLF force one style. Unicode line and paragraph separators (U+2028, U+2029) always become ordinary line breaks.

Troubleshooting pasted text

Code fails with "invalid character" but looks fine

A zero-width space (U+200B) or byte order mark (U+FEFF) is hiding in the text, often copied from a web page, chat app or a file saved by Windows Notepad. Keep Remove invisible characters on; the stats line tells you how many were found. Invisible characters explained lists every one the cleaner removes.

Two words will not match in a search or comparison

One of them probably contains a non-breaking space (U+00A0) from Word, a web page or a number formatted for French. Normalize spaces replaces it with a regular space.

Joiners in emoji, Indic and Persian text

Zero-width joiners (U+200D) and non-joiners (U+200C) are invisible but meaningful inside emoji sequences, such as the family emoji built from three people, and in scripts such as Devanagari and Persian. The cleaner keeps them in those places and removes them only where they sit between Latin letters, digits or spaces, so a‍b becomes ab while می‌خواهم is unchanged.

A word split across lines keeps its hyphen

When a line ends with a hyphen, Fix line breaks joins it to the next line without a space and keeps the hyphen, because a compound word cannot be told apart from a split one. self- + contained becomes self-contained, which is right, and exam- + ple becomes exam-ple, which you fix by hand. Search the result for - if the PDF hyphenated words.

Bullet points were joined into a paragraph

Lines are kept separate only when the next line starts with -, *, •, a digit, # or >. Lists using other symbols, such as o or ▪, are treated as wrapped text; replace the symbol before cleaning or leave Fix line breaks off.

The stats say "Your text is already clean."

None of the enabled chips found anything to change. Turn on further chips, such as Remove empty lines, if you expected a difference.

FAQ

How do I remove zero-width spaces from text?

Paste the text here with Remove invisible characters on, which is the default. Zero-width spaces, directional marks and BOMs are deleted, joiners are deleted outside emoji and non-Latin scripts, and the stats line reports the count. Turn on highlighting to see where each one was. In code, text.replace(/[\u200B-\u200D\uFEFF]/g, '') covers the usual cases, though not every invisible character.

How do I remove line breaks but keep paragraphs?

Use Fix line breaks, or the Fix PDF copy preset. It joins lines within a paragraph with a single space and keeps blank lines between paragraphs, so structure survives. If you want everything on one line with no paragraph breaks at all, use Remove all line breaks instead.

What is a non-breaking space and why does it cause problems?

A non-breaking space (U+00A0) looks like a space but stops a line from wrapping at that point. Word processors, web pages and some number formats insert it automatically. Code, CSV parsers and string comparisons treat it as a different character from a normal space, so identical-looking values fail to match.

Why does straightening quotes matter?

Curly quotes (“ ” ‘ ’) are typographic characters, not the ASCII quotes that programming languages, JSON, shells and SQL expect. Code pasted from a document or chat often has them, and it fails to parse. Straighten quotes & dashes converts them, along with en and em dashes, which break command-line flags like --force.

Does the Text Cleaner remove duplicate lines or sort text?

No. It focuses on whitespace, invisible characters, line breaks, quotes and line endings, and it never reorders or drops lines with content. Its job is to make text behave like what you see on screen without changing its meaning.

Is my text uploaded when I clean it?

No. Cleaning happens in your browser, in an isolated frame that blocks network requests. Chip settings are remembered on this device; your text is not stored unless you turn on "Remember my last input". Files over 10 MB are processed in a background worker, with highlighting disabled.

Strip headings and emphasis from Markdown first with Markdown to Plain Text, change identifier style with the Case Converter, or fix CRLF in a whole file with the Line Ending Converter. All text tools are listed under Text.

Browse all Text Formatting

Guides