Skip to content
ToolzKit

Text

Whitespace Cleaner

Trim, collapse and normalise whitespace, line endings and invisible characters in text.

Input

Output

Cleaned text appears here.

Paste text above to clean up whitespace.

About the Whitespace Cleaner

Whitespace Cleaner tidies up messy text copied from PDFs, emails or web pages. It can trim each line, collapse repeated spaces, remove or collapse blank lines, convert between tabs and spaces, normalise line endings between LF and CRLF, and strip invisible characters like zero-width spaces and non-breaking spaces that often cause subtle bugs.

How to use it

  1. 01Paste the text you want to clean into the input panel.
  2. 02Enable the cleaning options you need, such as trimming lines or collapsing blank lines.
  3. 03Choose tab-to-space or space-to-tab conversion and your preferred line-ending style.
  4. 04Copy or download the cleaned result, and check how many characters were removed.

Features

  • Trim each line and collapse multiple consecutive spaces
  • Remove blank lines entirely or collapse three or more into a single blank line
  • Convert tabs to spaces with a selectable width, or spaces to tabs
  • Normalise line endings to LF or CRLF, and strip zero-width and non-breaking characters

Practical examples

Cleaning pasted PDF text

Remove awkward extra spaces and blank lines left over after copying text out of a PDF document.

Fixing invisible characters

Strip zero-width spaces and non-breaking spaces that can break search-and-replace or code parsing.

Limitations

  • Space-to-tab conversion assumes groups of four spaces represent a tab and may not match every original indentation scheme.
  • Stripping invisible characters removes zero-width and non-breaking characters everywhere, including inside quoted text where they might have been intentional.

Privacy

All cleaning operations run locally in your browser; the text is never uploaded.

Read the full privacy policy for how the site as a whole handles data.

Frequently asked questions

What counts as a zero-width character?

This includes zero-width space, zero-width joiner, zero-width non-joiner and the byte-order-mark character, all of which are invisible but can affect text processing.

Will this change the meaning of code?

Converting tabs to spaces or vice versa can change indentation-sensitive code like Python, so review the output carefully before using it.

How is the 'characters removed' count calculated?

It's the difference in total character length between your original input and the cleaned output.