Tools

Categories

Text Cleaner

Clean up messy text: whitespace, line breaks, empty lines, and more

Before0 chars · 0 words · 0 lines
After0 chars · 0 words · 0 lines

Cleanup options

Clean Up Messy Text Online

This free text cleaner fixes the whitespace and formatting problems that appear when you copy text out of PDFs, emails, spreadsheets, chat apps, and word processors. In one pass it can collapse runs of spaces and tabs into a single space, trim every line, delete blank lines, remove all line breaks to reflow a paragraph, convert tabs to spaces (or spaces back to tabs), normalize line endings, strip HTML tags, straighten curly quotes and dashes to plain ASCII, and remove invisible control and zero-width characters. Live character, word, and line counts before and after show exactly what each option changed.

Every option is a toggle and the output updates instantly as you type or flip a switch, so you can layer cleanups until the text looks right. All processing runs locally in your browser with JavaScript — nothing you paste is uploaded, stored, or transmitted — so it is safe for private notes, source code, contracts, and unpublished copy.

How to use Text Cleaner

  1. Paste or type your messy text into the Input box.
  2. Turn on the cleanup options you need — collapsing spaces, trimming lines, and trimming the whole text are on by default.
  3. For tabs, choose Tabs to spaces or Spaces to tabs and set the tab width (2, 4, or 8).
  4. Watch the Before and After counts to confirm what changed; the output updates live.
  5. Copy the cleaned text to your clipboard or download it as a .txt file, and use Reset options to return to the defaults.

What each option does

  • Collapse multiple spaces/tabs into one space — turns any run of spaces and tabs into a single space, without touching line breaks.
  • Trim whitespace on each line — removes leading and trailing spaces and tabs from every line.
  • Remove empty (blank) lines — deletes lines that contain nothing but whitespace, closing up the gaps.
  • Remove all line breaks — joins everything into a single line, inserting one space at each former line break so words do not run together. This is separate from removing empty lines.
  • Trim start/end of the whole text — strips leading and trailing whitespace from the entire block.
  • Normalize line endings to LF — converts Windows CRLF and old Mac CR endings to plain LF newlines.
  • Remove control & zero-width characters — deletes non-printable control characters and invisible zero-width or formatting characters, while keeping tabs and newlines.
  • Strip HTML tags — removes markup such as <p> and <span>, leaving only the readable text.
  • Curly quotes & dashes to ASCII — replaces smart quotes with straight ' and ", en and em dashes with - and --, the ellipsis with three dots, and non-breaking spaces with normal spaces.
  • Tabs and spaces — convert tabs to a chosen number of spaces, or convert that many spaces back into a tab.

The order cleanups are applied

The options are not applied in the order they appear on screen; they run in a fixed, sensible sequence so the result is predictable no matter which boxes you tick. Line endings are normalized first, then HTML is stripped, then control and zero-width characters are removed, then curly punctuation is straightened. After that tabs and spaces are converted, runs of whitespace are collapsed, each line is trimmed, blank lines are removed, any remaining line breaks are joined, and finally the whole text is trimmed.

Because everything recomputes from your original input every time, toggling an option off instantly restores what it removed — you are never editing a one-way result, so you can experiment freely.

Common cleanup jobs

  • Reflow a paragraph copied from a PDF that broke every line — enable Remove all line breaks and Collapse multiple spaces.
  • Tidy a pasted list — enable Trim each line and Remove empty lines.
  • Prepare text for code — enable Tabs to spaces and Curly quotes & dashes to ASCII so smart quotes do not break a string literal.
  • Debug an invisible character — enable Remove control & zero-width characters to strip a stray byte order mark or zero-width space.
  • Extract readable text from an HTML snippet — enable Strip HTML tags.

Related terminology

Whitespace
Characters that create space but no visible glyph — the space, tab, and newline. Cleaning text usually means normalizing runs of whitespace down to single spaces and single line breaks.
Line ending (EOL)
The character(s) that mark the end of a line: LF (\n) on Unix and macOS, CRLF (\r\n) on Windows, and CR (\r) on classic Mac. Normalizing to LF avoids stray characters when text moves between systems.
Zero-width / control character
An invisible character that takes up no width or performs a formatting function, such as a zero-width space or a byte order mark. It is stored in the text even though you cannot see it, and can break parsing or comparisons.
Smart (curly) quotes
The typographic quotation marks and apostrophes (“ ” ‘ ’) that word processors insert automatically. They look nicer in prose but often break code and data, so this tool can convert them to straight ASCII quotes.
Tab width
The number of space characters a single tab represents when converting between tabs and spaces — commonly 2, 4, or 8.

Frequently asked questions

How do I remove extra spaces and blank lines from text?
Paste your text and keep Collapse multiple spaces/tabs into one space and Trim whitespace on each line enabled, then tick Remove empty (blank) lines. The cleaned result appears instantly on the right, and the Before and After counts show how many characters and lines were removed.
What is the difference between removing empty lines and removing all line breaks?
Remove empty (blank) lines deletes only the lines that are empty, keeping your remaining lines separate. Remove all line breaks goes further and joins everything into a single line, inserting a space at each former break so words do not merge — useful for reflowing a paragraph whose lines were hard-wrapped.
Can it convert tabs to spaces or spaces to tabs?
Yes. Choose Tabs to spaces or Spaces to tabs from the Tabs and spaces menu and set the tab width to 2, 4, or 8. Tabs to spaces replaces each tab with that many spaces; Spaces to tabs replaces each run of that many spaces with a single tab.
Does it remove invisible or non-printable characters?
Enable Remove control & zero-width characters. It strips non-printable control characters and invisible zero-width and formatting characters — such as a stray byte order mark or zero-width space — while preserving tabs and newlines so your layout is not destroyed.
Will it turn curly quotes into straight quotes?
Turn on Curly quotes & dashes to ASCII. It converts smart double and single quotes to straight " and ', en and em dashes to - and --, the ellipsis character to three dots, and non-breaking spaces to normal spaces — ideal for pasting prose into code or plain-text systems.
Is my text uploaded to a server?
No. All cleaning happens in your browser with JavaScript, so the text you paste never leaves your device — safe for private notes, source code, contracts, and unpublished drafts.

Related tools