How to use the text cleaner
- Paste your text into the input box.
- Check the boxes for the operations you need, such as Remove extra spaces or Strip HTML tags.
- The cleaned text appears instantly below as you toggle options.
- Review the stats line to see how many characters were removed.
- Copy the result to use elsewhere.
How the text cleaner processes your input
The tool applies transformations in a fixed order so results are predictable, and each option works on its own without needing another one to be ticked. The sequence is:
- Remove zero-width characters: strips U+200B (zero-width space), U+FEFF (byte order mark) and U+00AD (soft hyphen). U+200C and U+200D are kept unless you tick the separate joiner option.
- Normalize line endings: converts every CRLF (
\r\n) and standalone CR (\r) to a single LF (\n). - Strip HTML tags: removes real tags (an opening angle bracket followed by a letter or a slash, up to the closing bracket), comments and DOCTYPE declarations. Text such as
x < 5is left alone. - Straighten quotes: replaces left and right single quotes (U+2018, U+2019) with
', and left and right double quotes (U+201C, U+201D) with". Em dashes and en dashes are left untouched. - Trim lines: removes leading and trailing spaces and tabs from every line.
- Collapse spaces: replaces runs of two or more spaces within a line with a single space.
- Remove blank lines: deletes lines that are empty or contain only whitespace, with LF, CRLF or CR line endings, whether or not the other options are on.
This order matters. For example, stripping HTML tags before collapsing spaces prevents leftover markup from creating unexpected gaps.
Common invisible characters that break text
When you copy text from word processors, PDFs or web pages, invisible characters often come along. Zero-width spaces (U+200B) are used for optional line breaks but cause search mismatches. Byte order marks (U+FEFF) appear at the start of UTF-8 files and can break scripts. Soft hyphens (U+00AD) show up when text was wrapped in a layout engine.
A good text cleaner removes these without changing what you see on screen. Two invisible characters are special: the zero-width joiner (U+200D) glues emoji such as a family emoji into one picture, and the zero-width non-joiner (U+200C) is part of correct spelling in Persian and some Indic scripts, so this tool keeps both unless you opt in to removing them. If you need to inspect exactly what characters are present before cleaning, use a character frequency counter to see a breakdown of every code point in your string.
Practical uses for cleaning text
Developers use this tool to sanitize pasted snippets before committing code. Content editors clean up text from CMS exports where stray HTML tags or double spaces remain. Data analysts preparing CSV files often need to remove blank lines and normalize line endings so import scripts do not fail.
If your workflow also requires deduplication, pass the cleaned output through a tool to remove duplicate lines. For publishing URLs, you might want to run the final string through a url slug generator to produce safe permalinks.
What each option does in detail
| Option | Characters affected | Example input | Example output |
|---|---|---|---|
| Remove zero-width | U+200B, U+FEFF, U+00AD (add the joiner option for U+200C and U+200D) | a[U+200B]b | ab |
| Normalize line endings | CR, CRLF | a\r\nb | a\nb |
| Strip HTML tags | Real tags such as <b> and </p> | <b>hi</b> | hi |
| Straighten quotes | U+2018, U+2019, U+201C, U+201D | \u201Chi\u201D | "hi" |
| Trim lines | Leading/trailing spaces and tabs per line | hi | hi |
| Collapse spaces | Multiple consecutive spaces | a b | a b |
| Remove blank lines | Empty or whitespace-only lines | a\n\nb | a\nb |
Edge cases and limitations
Stripping HTML tags removes the markup (anything shaped like a tag, so a literal <word and more> in plain text would also go) but does not decode HTML entities like & or <. If you need entity decoding, handle that separately. The collapse-spaces option targets regular space characters (U+0020) only; it does not convert tabs or non-breaking spaces (U+00A0) into regular spaces. Tabs are preserved unless they sit at the start or end of a line and trim-lines is active.
When all options are turned off, the text cleaner returns your input completely unchanged, including any invisible characters or irregular spacing. The character removal count shown below the output reflects the difference in length between the original input and the final cleaned string.
Worked examples
| Example | Input | Result |
|---|---|---|
| Clean messy copied text | Input text: “Hello” world ; Remove zero-width and invisible characters: yes; Normalize line endings to LF: yes; Strip HTML tags: no; Straighten quotes: yes; Trim leading and trailing spaces on each line: yes; Collapse multiple spaces into one: yes; Remove blank lines: no | "Hello" world |
| Strip HTML and collapse spaces | Input text: <p>Hello <strong>world</strong></p>; Remove zero-width and invisible characters: no; Normalize line endings to LF: yes; Strip HTML tags: yes; Straighten quotes: no; Trim leading and trailing spaces on each line: yes; Collapse multiple spaces into one: yes; Remove blank lines: no | Hello world |
| Remove blank lines from a list | Input text: Apple / Banana / Cherry; Remove zero-width and invisible characters: no; Normalize line endings to LF: yes; Strip HTML tags: no; Straighten quotes: no; Trim leading and trailing spaces on each line: no; Collapse multiple spaces into one: no; Remove blank lines: yes | Apple / Banana / Cherry |
| Straighten quotes only | Input text: ‘Don’t’ stop “believing”; Remove zero-width and invisible characters: no; Normalize line endings to LF: no; Strip HTML tags: no; Straighten quotes: yes; Trim leading and trailing spaces on each line: no; Collapse multiple spaces into one: no; Remove blank lines: no | 'Don't' stop "believing" |
FAQ
Does this text cleaner upload my data?
No. All processing happens locally in your browser using JavaScript. Your text is never sent to any server.
What invisible characters does it remove?
When the zero-width option is enabled, it removes U+200B, U+FEFF and U+00AD. U+200C and U+200D are kept by default because removing them breaks emoji sequences and Persian or Indic text; tick the joiner option to remove them too.
Will it change em dashes or en dashes?
No. The straighten-quotes option only converts curly single and double quotation marks to their straight equivalents. Dashes are left intact.
Can I remove extra spaces without deleting blank lines?
Yes. Enable collapse spaces and leave remove blank lines unchecked. Each option works independently.
Does stripping HTML tags decode entities?
No. It only removes the angle-bracket markup. Entities like remain as literal text. Use a dedicated decoder if you need entity conversion.
How do I clean up text that has duplicate entries too?
First use this tool to remove extra spaces and formatting, then pass the result to a remove duplicate lines utility.