Whitespace Trimmer & Text Cleaner
Remove extra spaces, blank lines, leading and trailing whitespace, and clean up messy text formatting in one click.
Runs in your browser. No data leaves your device.
About this tool
Cleans up stray whitespace in text with four independent toggles and shows how many characters were removed. Use it on text copied from PDFs, emails or web pages before pasting it somewhere else.
Features
- Trim each line (on by default): removes leading and trailing whitespace from every line
- Collapse multiple spaces (on by default): replaces each run of two or more spaces or tabs with a single space (a lone tab is kept)
- Windows (CRLF) line endings are converted to LF
- Remove blank lines (off by default): deletes every empty or whitespace-only line
- Trim start/end (on by default): trims whitespace from the start and end of the whole text
- Live output with copy and pipeline buttons
- Stats line: original characters, cleaned characters, number removed and percentage reduction
How to use it
- Paste text into the Input box.
- Turn the four cleanup options on or off.
- Copy the cleaned Output.
Inputs
- Any plain text
Outputs
- Cleaned text and a character-reduction summary
Limits and notes
- Remove blank lines removes all blank lines, including paragraph breaks; there is no option to collapse several blank lines into one.
- Collapse multiple spaces also replaces runs of tabs (e.g. indentation); to keep code indentation, turn off both Collapse multiple spaces and Trim each line.
- Zero-width and other invisible characters are not removed; use the Hidden Characters tool for those.
- Text is not saved and nothing is uploaded.
Frequently Asked Questions
How does the Whitespace Trimmer work?
Four independent options run in order. Trim each line splits the text into lines and trims each one. Collapse multiple spaces replaces every run of two or more spaces or tabs with a single space. Remove blank lines deletes every empty or whitespace-only line. Trim start/end calls trim() on the whole result. The output and a count of removed characters update live.
What types of whitespace does it remove?
Leading and trailing spaces on each line, multiple consecutive spaces, extra blank lines, tabs, and other invisible whitespace characters. You can toggle each cleaning option independently.
Will it remove line breaks between paragraphs?
Only if you turn on Remove blank lines, which deletes every blank line, including paragraph breaks. With it off (the default), blank lines are kept. There is no option to collapse several blank lines into one.
What is this useful for?
Cleaning up text copied from PDFs, emails, or web pages that often contain extra spaces and formatting artifacts. Also useful for cleaning code, CSV data, and any messy text before processing.