Whitespace Remover and Trimmer
Remove extra whitespace, trim leading and trailing spaces, collapse multiple spaces, and clean up messy text formatting.
Whitespace Remover and Trimmer tool
Example
Input: Hello world, how are you? typed with 3 leading spaces, 2 to 5 spaces between words and 3 trailing spaces
Result: Hello world, how are you?
Leading and trailing spaces are trimmed and every run of spaces or tabs inside a line is collapsed to a single space.
- Paste the text with unwanted spaces into the input area.
- Choose the cleaning options: Trim Lines, Collapse Spaces and Remove Blank Lines.
- Turn each option on or off to get the cleanup you need.
- Compare the cleaned text in the output with your original.
- Click the copy button to copy the cleaned text.
Cleaning Up Extra Spaces, Tabs and Blank Lines
The Whitespace Remover cleans up messy spacing in text. By default it trims spaces from the start and end of every line, and it squeezes runs of spaces and tabs into a single space, so "Hello world" becomes "Hello world". A third option deletes blank lines.
Each option is a switch you can turn on or off. Trim Lines removes indents and trailing spaces. Collapse Spaces shrinks gaps inside a line. It also turns tabs into single spaces, so switch it off if you need to keep tab-separated columns. Remove Blank Lines deletes empty lines, including lines that hold only spaces. The breaks between lines of text are always kept, so paragraphs and lists keep their shape.
Hidden spaces are often the real problem. Text copied from a PDF, web page or email can contain non-breaking spaces and other special spaces. They look normal but break searches, formulas and code. This tool handles them too: Trim Lines removes them from the ends of lines, and Collapse Spaces turns them into ordinary spaces. Zero-width characters do not count as spaces here, so they are left alone. After cleaning, you can drop repeated lines with Remove Duplicate Lines. To strip zero-width characters, search for them with Find and Replace in regex mode.
Frequently Asked Questions
Related Tools
Remove Duplicate Lines
Remove duplicate lines from text while keeping the original order. Supports case-sensitive and case-insensitive modes.
Text and WritingFind and Replace
Find and replace text with regular expressions, capture groups, case-sensitive matching, and a live match count.
Text and WritingCase Converter
Convert text between UPPER, lower, Title, Sentence, camelCase, snake_case, kebab-case, CONSTANT_CASE, and PascalCase.
Text and WritingWord Counter and Character Counter
Count words, characters, sentences, and paragraphs in your text. Includes reading time and speaking time estimates.
Text and Writing