Trim Whitespace (Leading, Trailing, Multiple Spaces)

Clean up text with messy whitespace — trim trailing spaces, collapse runs of spaces, remove blank lines, normalize line endings. Useful for cleaning copy-pasted content, log files, code snippets.

How to use the Trim Whitespace (Leading, Trailing, Multiple Spaces)

Paste text and tick which cleanups to apply — trim leading and trailing whitespace per line, collapse runs of spaces to one, remove blank lines, normalize CRLF to LF — then copy the cleaned output. Changes apply live as you toggle.

Cleaning up messy whitespace in one pass

Copy-pasted text tends to arrive dirty: trailing spaces left by a code editor, double spaces from old typing habits, blank lines from a PDF export, stray indentation from a web form. Each is harmless alone, but together they break diffs, inflate file size, and trip up parsers that expect tidy input.

This tool applies the common cleanups in a single pass — trim leading and trailing whitespace, collapse repeated spaces, drop blank lines, normalize line endings — with each rule as its own toggle so you keep what you want. To convert tabs to spaces specifically, use tab to space; to switch line-ending style across a whole file, the line ending converter; to remove repeated lines, deduplicate lines.

Common use cases

  • Cleaning copy-paste — strip the trailing spaces and blank lines a paste drags in.
  • Diff hygiene — remove trailing-whitespace noise before committing.
  • Data prep — collapse irregular spacing in a column of pasted values.
  • Prose tidy-up — fix double spaces after periods in one go.
  • Log trimming — drop blank lines from a captured log.

Frequently asked questions

Does it convert tabs?

Collapsing runs of spaces targets spaces. To turn tabs into spaces (or the reverse), use tab to space.

Will it remove indentation I want to keep?

Only if you enable “trim leading.” Leave it off to preserve indentation and clean just the trailing whitespace.

Can it remove blank lines?

Yes — an optional toggle drops empty lines entirely rather than leaving gaps.

Does it change line endings?

Only if you turn on normalize CRLF→LF. Otherwise your existing line endings are left as they are.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: