Whitespace Cleaner

Choose whether to clean spaces and line edges together, trim edges only, or collapse spaces and tabs while keeping edge spacing.

Text is processed locally in your browser and is not uploaded.

Characters removed
9
Page guide

How to use this tool

  1. Paste the text and choose a cleanup mode.
  2. Choose whether three or more consecutive newlines should become one blank line. Review the live output.
  3. Copy or download the result, or use it as the input for another pass. Undo last replacement restores the text before a replacement or clear.

Understanding the output

Clean spaces and line edges converts horizontal whitespace runs to one space and trims each line and the passage edges. Trim line edges only keeps spacing inside lines. Collapse spaces and tabs only converts runs but leaves one space at populated line edges. Every mode normalizes CRLF and CR to LF. Optional blank-line collapse replaces three or more consecutive LF characters with two; a whitespace-only line can interrupt that run. Characters removed measures UTF-16 code units, including normalized line endings.

Cleaning a spaced line

A line containing two leading spaces, A, three spaces, spaced, a tab, and line. becomes A spaced line. Two paragraphs remain separate after cleanup.

Repair copy-and-paste spacing carefully

Text copied from a PDF, email, or document can contain runs of spaces, tabs, and nonbreaking spaces. These can make a passage difficult to edit or cause unexpected matches when searching. Normalizing spacing is useful for ordinary prose, but it also removes deliberate alignment created with spaces. Keep the original when that alignment conveys meaning.

If the source is a table, consider converting it with a data-aware tool instead. Whitespace alone may be separating columns, and turning several spaces into one can erase the only visible distinction between neighboring values.

Preserve paragraphs while reducing clutter

A blank line often separates ideas, whereas three or four blank lines usually create unnecessary gaps in a pasted draft. The optional blank-line cleanup reduces those larger gaps to a single paragraph separator. It does not decide whether two adjacent lines belong to the same sentence. Use the dedicated line-break remover when the text is hard-wrapped and should flow continuously.

Method and supported input

The selected mode applies horizontal-whitespace replacement, edge trimming, or both. Line endings normalize to LF; optional blank-line collapse operates on consecutive LF characters after the selected cleanup.

  • The input is prose or another format where repeated horizontal spaces are not significant.

Limitations

  • Depending on the chosen mode, edge indentation or horizontal spacing changes. All modes normalize line endings.
  • Do not use this on source code, poetry, or structured data unless the spacing changes are intentional.

Common questions

Will this remove all line breaks?

No. Ordinary line breaks remain. Extra blank lines are collapsed only when the option is enabled.

Are nonbreaking spaces preserved?

Space-cleaning modes normalize horizontal nonbreaking whitespace to ordinary spaces. Trim-only mode preserves internal spacing but removes it at line edges.

Can I keep spaces inside a line?

Yes. Select Trim line edges only to preserve internal spaces and tabs. All modes still normalize line endings.

Sources and further reading

Reviewed on