Whitespace Trimmer
Remove extra whitespace
What Is This Tool?
The Whitespace Trimmer cleans up messy text by trimming leading/trailing whitespace on each line, collapsing repeated spaces, removing blank lines, and converting tabs to a fixed number of spaces. It's useful for tidying up text copied from PDFs, emails, or other sources that introduce irregular spacing.
How to Use
Paste your text into the input box.
Choose which cleanup options to apply.
Click Clean to see the tidied result.
Copy or download the cleaned text.
Features
- Trims leading/trailing whitespace on every line
- Collapses runs of spaces into a single space
- Removes blank lines entirely, if wanted
- Converts tabs to a configurable number of spaces
- 100% client-side — nothing leaves your browser
Examples
Input:
Hello World Tabbed line Another line here
Output (all options on, tab width 4):
Hello World
Tabbed line
Another line here
Common Use Cases
- Cleaning up text pasted from a PDF or web page
- Normalizing indentation and spacing before sharing code snippets
- Removing stray blank lines from a document
- Preparing text for diffing or comparison tools
Frequently Asked Questions
What does "Trim each line" do?
It removes leading and trailing spaces or tabs from every individual line, without affecting the spacing between words in the middle of a line.
What does "Collapse multiple spaces" do?
Any run of two or more consecutive spaces within a line is replaced with a single space. Tabs are not affected unless "Convert tabs to spaces" is also enabled.
How does tab conversion work?
Each tab character is replaced with the number of spaces set in the tab width field (default 4), which then behaves like regular spaces for the collapse option.
Will this remove indentation I want to keep?
Yes, "Trim each line" removes all leading whitespace including intentional indentation. Uncheck it if you want to preserve leading spaces on each line.
Is my text sent anywhere?
No. All cleaning happens entirely in your browser using JavaScript. Nothing is uploaded or stored.