Skip to main content
ponderloop

Text Cleaner

With the default settings the example text below loses 20 of 149 characters: 10 lines become 6 and its 24 words stay 24, because the doubled spaces and tabs, the indents, the hidden zero-width space, the non-breaking space, the curly quotes and dashes, the extra blank lines and the accent typed as two characters are all fixed. Paste your own text, tick the clean-ups you want and they run in one fixed order (10 rules); each one reports how many items it removed, so you can see exactly what changed before you copy the result. HTML tags can be stripped too, and the text is cleaned on this device without being sent anywhere.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Cleaned on this device

Replace the example: paste or type your text. The result updates as you type.

Nothing is uploaded or saved: reload the page and your text is gone. Up to 1,048,576 characters.

Characters

Also removes U+200C and U+200D, which some emoji and scripts need.

Simple: tags only, no entities. For a full conversion use the HTML to Text Converter.

Spaces and lines

Cleaned text

20 of 149 characters removed

149 characters to 129 (20 removed); 10 lines to 6 (4 removed); 24 words to 24.

What changed

Characters, lines and words before and after cleaning
CountBeforeAfterRemoved
Characters14912920
Lines1064
Words24240
What each rule did, in the order the rules run
StepRuleResult
1Strip HTML tagsOff
2Normalize Unicode (NFC)1 character merged
3Remove zero-width and control characters1 character removed
4Normalize non-breaking spaces1 space replaced
5Plain quotes, dashes and ellipsis4 characters replaced
6Trim each line13 characters removed
7Blank lines3 lines removed
8Remove line breaksOff
9Collapse repeated spaces and tabs2 characters removed
10Trim the whole text2 characters removed

Hidden characters removed

  • U+200B zero width space ×1

The rules, in the order they run

Each row is the real result of the cleaner with only that rule on. “·” is a space, “→” a tab, “↵” a line break and “[U+XXXX]” a character you cannot see.
StepRuleBeforeAfterWhat it does
1Strip HTML tags<p>Hi·<b>there</b></p><!--·note·-->Hi·thereRemoves tags, closing tags, comments and doctypes, and inserts nothing in their place. Entities (&amp;) are not decoded.
2Normalize Unicode (NFC)Cafe[U+0301]CaféJoins a letter and its combining accent into the single precomposed character, so the same word always has the same code points.
3Remove zero-width and control characterszero[U+200B]width[U+0007]zerowidthDeletes zero-width characters and control characters other than tab and line feed.
4Normalize non-breaking spacesa[NBSP]b[U+202F]ca·b·cTurns the three non-breaking spaces into ordinary spaces.
5Plain quotes, dashes and ellipsis“Hi”·—·it’s…"Hi"·-·it's...Curly quotes become straight ones, every dash a hyphen, the ellipsis three full stops.
6Trim each line··a··↵→b→a↵bRemoves spaces, tabs and other space characters at both ends of every line.
7Blank linesa↵↵↵↵ba↵↵bA run of blank lines becomes one blank line (or none, with “Remove all blank lines”).
8Remove line breaksone↵two↵↵threeone·two↵↵threeJoins the lines of a paragraph with one space; blank lines stay when paragraph breaks are kept.
9Collapse repeated spaces and tabsa···b→→ca·b·cA run of two or more spaces or tabs becomes one space. A lone tab stays.
10Trim the whole text↵↵··a··↵aRemoves whitespace and line breaks before the first and after the last character.

Characters that are removed or replaced

Every character the cleaner changes, with its code point. Control characters are listed as ranges.
Code pointNameRuleBecomes
U+200Bzero width spaceZero-width and control charactersRemoved
U+200Czero width non-joinerZero-width and control charactersRemoved
U+200Dzero width joinerZero-width and control charactersRemoved
U+2060word joinerZero-width and control charactersRemoved
U+FEFFzero width no-break space (byte order mark)Zero-width and control charactersRemoved
U+0000–U+0008, U+000B–U+001F, U+007F–U+009FControl characters (C0 except tab and line feed, delete, C1)Zero-width and control charactersRemoved
U+00A0no-break spaceNon-breaking spacesSpace (U+0020)
U+2007figure spaceNon-breaking spacesSpace (U+0020)
U+202Fnarrow no-break spaceNon-breaking spacesSpace (U+0020)
U+2018 (‘)left single quotation markPlain quotes, dashes and ellipsisstraight apostrophe (')
U+2019 (’)right single quotation markPlain quotes, dashes and ellipsisstraight apostrophe (')
U+201A (‚)single low-9 quotation markPlain quotes, dashes and ellipsisstraight apostrophe (')
U+201B (‛)single high-reversed-9 quotation markPlain quotes, dashes and ellipsisstraight apostrophe (')
U+201C (“)left double quotation markPlain quotes, dashes and ellipsisstraight double quote (")
U+201D (”)right double quotation markPlain quotes, dashes and ellipsisstraight double quote (")
U+201E („)double low-9 quotation markPlain quotes, dashes and ellipsisstraight double quote (")
U+201F (‟)double high-reversed-9 quotation markPlain quotes, dashes and ellipsisstraight double quote (")
U+2010 (‐)hyphenPlain quotes, dashes and ellipsishyphen-minus (-)
U+2011 (‑)non-breaking hyphenPlain quotes, dashes and ellipsishyphen-minus (-)
U+2012 (‒)figure dashPlain quotes, dashes and ellipsishyphen-minus (-)
U+2013 (–)en dashPlain quotes, dashes and ellipsishyphen-minus (-)
U+2014 (—)em dashPlain quotes, dashes and ellipsishyphen-minus (-)
U+2015 (―)horizontal barPlain quotes, dashes and ellipsishyphen-minus (-)
U+2026 (…)horizontal ellipsisPlain quotes, dashes and ellipsisthree full stops (...)

Worked examples

Real results of the cleaner. Only the options in the second column are on. “·” is a space, “→” a tab and “↵” a line break.
ExampleOptionsTextResult
Extra spacesCollapse repeated spaces and tabsHello···world,→→this··has···gaps.Hello·world,·this·has·gaps.
Too many blank linesblank lines collapsed to oneIntro↵↵↵↵Body↵↵↵EndIntro↵↵Body↵↵End
Every blank lineall blank lines removeda↵↵b↵··↵ca↵b↵c
Hard-wrapped textRemove line breaks (keep paragraph breaks)The·quick·brown·fox↵jumps·over·the·lazy↵dog.↵↵A·new·paragraph↵starts·here.The·quick·brown·fox·jumps·over·the·lazy·dog.↵↵A·new·paragraph·starts·here.
Everything on one lineRemove line breaksThe·quick·brown·fox↵jumps·over·the·lazy↵dog.↵↵A·new·paragraph↵starts·here.The·quick·brown·fox·jumps·over·the·lazy·dog.·A·new·paragraph·starts·here.
Text from a word processorPlain quotes, dashes and ellipsis“It’s·done”·–·she·said…"It's·done"·-·she·said...
Text from a web pageRemove zero-width and control characters + Normalize non-breaking spaces + Collapse repeated spaces and tabs + Trim the whole text·Price:[NBSP][NBSP]$5[U+200B].00·Price:·$5.00
Markup left in a pasteStrip HTML tags + all blank lines removed + Trim the whole text<h1>Title</h1>↵<p>Some·<em>text</em>.</p>↵Title↵Some·text.

How to clean up pasted text

  1. Paste your text. Replace the example with your own text. The result updates as you type, and nothing is sent anywhere.
  2. Tick the clean-ups you want. Trim each line, collapse repeated spaces and tabs, handle blank lines, replace smart quotes and dashes, remove hidden characters, normalize non-breaking spaces. Leave the rest off.
  3. Join lines only if you need to. Turn on “Remove line breaks” for text that was hard-wrapped (from a PDF or an email), and keep “Keep paragraph breaks” on to leave the gaps between paragraphs.
  4. Check what changed. The table beside the result lists every rule with the number of items it removed or replaced, and any hidden characters found, by code point.
  5. Copy the result. Press Copy and paste the clean text where you need it. Clear empties the box for the next piece of text.

Frequently asked questions

How do I remove extra spaces from text?
Tick “Collapse repeated spaces and tabs”: every run of two or more spaces or tabs becomes one space (“a···b→→c” becomes “a·b·c”), and “Trim each line” removes the spaces at the start and end of each line. A lone tab is left alone, so tab-separated text keeps its columns (“a→b→c”). Spaces that look normal but are not (non-breaking spaces) need “Normalize non-breaking spaces”, which runs first.
How do I remove blank lines?
Choose “Remove all blank lines” to delete every empty line, or “Collapse to one blank line” to keep a single gap wherever there were several (“a↵↵↵↵b” becomes “a↵↵b”). A line that holds only spaces or tabs counts as blank. The line break that ends your text is not a blank line, and “Trim the whole text” removes a blank line left at the very top or bottom.
How do I remove line breaks from text copied from a PDF or an email?
Turn on “Remove line breaks”. Each paragraph’s lines are joined with one space (“one↵two” becomes “one two”). With “Keep paragraph breaks” on, the blank lines between paragraphs stay: the example “The·quick·brown·fox↵jumps·over·the·lazy↵dog.↵↵A·new·paragraph↵starts·here.” becomes “The·quick·brown·fox·jumps·over·the·lazy·dog.↵↵A·new·paragraph·starts·here.”. With it off, everything becomes a single line (“The·quick·brown·fox·jumps·over·the·lazy·dog.·A·new·paragraph·starts·here.”). A word hyphenated across two lines is not repaired: “exam-↵ple” becomes “exam- ple”.
How do I replace smart quotes and curly quotes with straight ones?
Tick “Plain quotes, dashes and ellipsis”. Curly single quotes and apostrophes become ', curly double quotes become ", every dash (hyphen, non-breaking hyphen, figure dash, en dash, em dash, horizontal bar) becomes a hyphen-minus, and the ellipsis character becomes three full stops: ““It’s” — ‘ok’…” becomes “"It's" - 'ok'...”. Guillemets (« »), the minus sign (−) and the Hebrew geresh and gershayim are real punctuation in their languages and are left alone.
Which zero-width and control characters are removed?
Zero-width: U+200B zero width space, U+200C zero width non-joiner, U+200D zero width joiner, U+2060 word joiner, U+FEFF zero width no-break space (byte order mark). Control: U+0000–U+0008, U+000B–U+001F, U+007F–U+009F, which covers the ASCII control codes other than tab and line feed (line breaks are handled separately), delete, and the C1 range. The result list under the text shows which of these were found, by code point and with a count. Left in place on purpose: left-to-right and right-to-left marks and the embedding controls (they decide how Hebrew and Arabic text is ordered), the soft hyphen (U+00AD) and variation selectors (“a[U+200E]b[U+00AD]c” is left as “a[U+200E]b[U+00AD]c”).
Will removing zero-width characters break emoji or Persian text?
It can, so turn the rule off for text like that. Some emoji are several emoji glued together with a zero width joiner, and removing the joiner separates them (the woman technologist emoji, a woman joined to a laptop, becomes “👩💻”). Persian and a few other scripts use the zero width non-joiner inside words, and removing it joins letters that should stay apart. To find one stray character without touching the rest, look at the text in the Unicode Character Inspector instead.
What is a non-breaking space, and why replace it?
A non-breaking space looks like a space but is a different character (U+00A0 no-break space, U+2007 figure space, U+202F narrow no-break space), so it is not matched when you search for a space, is not trimmed by tools that only know the ordinary space, and breaks comparisons and imports. Web pages and word processors insert them freely. “Normalize non-breaking spaces” turns each into an ordinary space, and because it runs before trimming and collapsing, the spaces it produces are then trimmed and collapsed like any other.
What does Normalize Unicode (NFC) do?
An accented letter can be stored as one character (é, U+00E9) or as a letter followed by a combining accent (e, then U+0301). Both look identical, but they are not equal when compared. NFC (normalization form C) composes the pair into the single character: “Cafe[U+0301]” (5 characters) becomes “Café” (4). Use it before comparing, sorting or de-duplicating text. It does not change compatibility characters such as the fi ligature (that would be NFKC), and it never changes how the text looks.
Does it strip HTML properly?
It is a simple tag stripper. A “<” followed by a letter, “/” and a letter, “!” or “?” starts a tag, which ends at the next “>”; comments end at “-->”. Nothing is put where a tag was (“Hello<br>World” becomes “HelloWorld”), entities stay as written (“Fish &amp; chips” stays “Fish &amp; chips”), the text inside script and style elements stays (“A<script>x()</script>B” becomes “Ax()B”), and a “>” inside a quoted attribute ends the tag early (“<a title="1>0">x</a>” becomes “0">x”). For a real conversion that decodes entities, drops scripts and keeps lists and tables readable, use the HTML to Text Converter. Tags are only removed from the text and are never put into this page as markup.
In what order are the rules applied, and does it matter?
Always the same: 1. Strip HTML tags; 2. Normalize Unicode (NFC); 3. Remove zero-width and control characters; 4. Normalize non-breaking spaces; 5. Plain quotes, dashes and ellipsis; 6. Trim each line; 7. Blank lines; 8. Remove line breaks; 9. Collapse repeated spaces and tabs; 10. Trim the whole text. The order matters because each rule works on the output of the one before: hidden characters go before trimming, so a zero-width space cannot shield a space from “Trim each line” (“[U+200B]··a” stays “[U+200B]··a” with trimming alone and becomes “a” with both on); tags go first so the lines they leave empty can be removed as blank lines; joining lines comes before collapsing, so spaces left by the join are collapsed; and trimming the whole text is last, so a blank line left at the top is removed. To apply a different order, copy the result and clean it again with other options.
Can it remove duplicate lines, change case or sort?
No, the cleaner never deletes repeated lines, reorders or recases anything: it only removes or replaces the characters and line breaks you tick. For those jobs use the Remove Duplicate Lines tool, the Case Converter or Sort Lines Alphabetically. A good order is to clean the text here first, so lines that differ only by a stray space or a hidden character compare equal afterwards.
How much text can I paste, and what happens to Windows line endings?
Up to 1,048,576 characters (about 1 MB of ordinary text); above that the page asks you to clean it in parts. Line endings are always converted to a plain line feed first, whatever the source used (Windows CRLF, old Mac CR, and the Unicode line and paragraph separators), and the number converted is shown: “a\r\nb” reports 1 converted.

How it works

The text is first stripped of line-ending variants (CRLF, CR, NEL, line separator and paragraph separator all become LF). The 10 rules then run in the order listed above, each on the output of the one before, and only the ones you tick. Strip HTML tags scans for “<” followed by a letter, “/” and a letter, “!” or “?” and removes up to the next “>” (comments up to “-->”); it runs in one pass and an unclosed tag is left as text. Normalize Unicode applies form NFC with the browser’s String.prototype.normalize, and the count is the number of code points that merged away. Zero-width and control characters are removed by code point: the zero-width set listed in the table, C0 controls other than tab and line feed, delete and C1 controls; the removed ones are counted per code point. Non-breaking spaces and smart punctuation are replaced from fixed tables (shown above). Trimming treats a tab and every Unicode space separator (category Zs) as a space; a blank line is one that holds nothing else. Collapsing replaces each run of two or more spaces or tabs by one space and counts the characters dropped. Joining lines puts one space between the lines of a paragraph; the count is the number of line breaks that disappeared. Characters are counted as code points (an emoji counts once), lines as line-break-separated pieces without the final break, and words as runs of non-whitespace. Every step is linear in the length of the text, and the page refuses more than 1,048,576 characters. The text is processed in the page itself: no request is made with it, it is not stored, and the analytics event records only that the tool was used.

Sources

All text & filesAll toolsHome & DIY calculators