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
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.
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
| Count | Before | After | Removed |
|---|---|---|---|
| Characters | 149 | 129 | 20 |
| Lines | 10 | 6 | 4 |
| Words | 24 | 24 | 0 |
| Step | Rule | Result |
|---|---|---|
| 1 | Strip HTML tags | Off |
| 2 | Normalize Unicode (NFC) | 1 character merged |
| 3 | Remove zero-width and control characters | 1 character removed |
| 4 | Normalize non-breaking spaces | 1 space replaced |
| 5 | Plain quotes, dashes and ellipsis | 4 characters replaced |
| 6 | Trim each line | 13 characters removed |
| 7 | Blank lines | 3 lines removed |
| 8 | Remove line breaks | Off |
| 9 | Collapse repeated spaces and tabs | 2 characters removed |
| 10 | Trim the whole text | 2 characters removed |
Hidden characters removed
- U+200B zero width space ×1
No zero-width or control characters were removed.
The rules, in the order they run
| Step | Rule | Before | After | What it does |
|---|---|---|---|---|
| 1 | Strip HTML tags | <p>Hi·<b>there</b></p><!--·note·--> | Hi·there | Removes tags, closing tags, comments and doctypes, and inserts nothing in their place. Entities (&) are not decoded. |
| 2 | Normalize 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. |
| 3 | Remove zero-width and control characters | zero[U+200B]width[U+0007] | zerowidth | Deletes zero-width characters and control characters other than tab and line feed. |
| 4 | Normalize non-breaking spaces | a[NBSP]b[U+202F]c | a·b·c | Turns the three non-breaking spaces into ordinary spaces. |
| 5 | Plain quotes, dashes and ellipsis | “Hi”·—·it’s… | "Hi"·-·it's... | Curly quotes become straight ones, every dash a hyphen, the ellipsis three full stops. |
| 6 | Trim each line | ··a··↵→b→ | a↵b | Removes spaces, tabs and other space characters at both ends of every line. |
| 7 | Blank lines | a↵↵↵↵b | a↵↵b | A run of blank lines becomes one blank line (or none, with “Remove all blank lines”). |
| 8 | Remove line breaks | one↵two↵↵three | one·two↵↵three | Joins the lines of a paragraph with one space; blank lines stay when paragraph breaks are kept. |
| 9 | Collapse repeated spaces and tabs | a···b→→c | a·b·c | A run of two or more spaces or tabs becomes one space. A lone tab stays. |
| 10 | Trim the whole text | ↵↵··a··↵ | a | Removes whitespace and line breaks before the first and after the last character. |
Characters that are removed or replaced
| Code point | Name | Rule | Becomes |
|---|---|---|---|
| U+200B | zero width space | Zero-width and control characters | Removed |
| U+200C | zero width non-joiner | Zero-width and control characters | Removed |
| U+200D | zero width joiner | Zero-width and control characters | Removed |
| U+2060 | word joiner | Zero-width and control characters | Removed |
| U+FEFF | zero width no-break space (byte order mark) | Zero-width and control characters | Removed |
| U+0000–U+0008, U+000B–U+001F, U+007F–U+009F | Control characters (C0 except tab and line feed, delete, C1) | Zero-width and control characters | Removed |
| U+00A0 | no-break space | Non-breaking spaces | Space (U+0020) |
| U+2007 | figure space | Non-breaking spaces | Space (U+0020) |
| U+202F | narrow no-break space | Non-breaking spaces | Space (U+0020) |
| U+2018 (‘) | left single quotation mark | Plain quotes, dashes and ellipsis | straight apostrophe (') |
| U+2019 (’) | right single quotation mark | Plain quotes, dashes and ellipsis | straight apostrophe (') |
| U+201A (‚) | single low-9 quotation mark | Plain quotes, dashes and ellipsis | straight apostrophe (') |
| U+201B (‛) | single high-reversed-9 quotation mark | Plain quotes, dashes and ellipsis | straight apostrophe (') |
| U+201C (“) | left double quotation mark | Plain quotes, dashes and ellipsis | straight double quote (") |
| U+201D (”) | right double quotation mark | Plain quotes, dashes and ellipsis | straight double quote (") |
| U+201E („) | double low-9 quotation mark | Plain quotes, dashes and ellipsis | straight double quote (") |
| U+201F (‟) | double high-reversed-9 quotation mark | Plain quotes, dashes and ellipsis | straight double quote (") |
| U+2010 (‐) | hyphen | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2011 (‑) | non-breaking hyphen | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2012 (‒) | figure dash | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2013 (–) | en dash | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2014 (—) | em dash | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2015 (―) | horizontal bar | Plain quotes, dashes and ellipsis | hyphen-minus (-) |
| U+2026 (…) | horizontal ellipsis | Plain quotes, dashes and ellipsis | three full stops (...) |
Worked examples
| Example | Options | Text | Result |
|---|---|---|---|
| Extra spaces | Collapse repeated spaces and tabs | Hello···world,→→this··has···gaps. | Hello·world,·this·has·gaps. |
| Too many blank lines | blank lines collapsed to one | Intro↵↵↵↵Body↵↵↵End | Intro↵↵Body↵↵End |
| Every blank line | all blank lines removed | a↵↵b↵··↵c | a↵b↵c |
| Hard-wrapped text | Remove 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 line | Remove line 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. |
| Text from a word processor | Plain quotes, dashes and ellipsis | “It’s·done”·–·she·said… | "It's·done"·-·she·said... |
| Text from a web page | Remove 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 paste | Strip 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
- Paste your text. Replace the example with your own text. The result updates as you type, and nothing is sent anywhere.
- 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.
- 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.
- 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.
- 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 & chips” stays “Fish & 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
- Unicode Standard Annex #15: Unicode Normalization Forms
- Unicode Standard Annex #14: Unicode Line Breaking Algorithm (mandatory breaks, no-break spaces)
- Unicode Standard Annex #44: Unicode Character Database (general categories Zs, Cf and Cc)
- The Unicode Standard: General Punctuation block, U+2000 to U+206F (code charts)
- MDN: String.prototype.normalize()
- WHATWG HTML Standard: tokenization (how browsers read tags and comments)
- ECMA-48 / ISO/IEC 6429: control functions for coded character sets (C0 and C1 controls)
More free tools
- HTML to Text ConverterPaste HTML and get plain text: tags, scripts and comments removed, entities decoded, lists, links and tables kept readable. Runs in your browser.
- Unicode Character InspectorPaste text to see every character: graphemes, code points, UTF-8 and UTF-16, escapes, category, script, hidden characters and look-alike letters.
- Find and ReplaceFind and replace text online: match case or whole words, use regular expressions with $1, run several pairs in order, and replace all or one by one.
- Remove Duplicate LinesRemove duplicate lines from a list, keep the first or last copy, and sort A to Z, naturally or at random. Works in any language and stays in your browser.
- Word CounterCount words, characters, sentences and reading time, and check your text against X, LinkedIn, Instagram, SMS and meta description limits.
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE. Stays in your browser.