How to use
Paste the padded text
Paste into the Text with extra whitespace box, or press Try sample to load lines with leading spaces, trailing spaces, a tab and double spaces between words.
Choose what to trim
In the Trim menu pick Both ends, Leading only, Trailing only or All spaces and tabs. Choose what happens to Blank lines, and tick the collapse, odd spaces or zero-width options if needed.
Check and copy
The Trimmed text pane updates as you type, and the counter shows how many characters were removed. Press Copy, or Download .txt to save the clean text.
Why Trim Whitespace
- Trims the start, the end, both ends, or every space in each line.
- Collapses double spaces between words without touching indentation.
- Keeps, reduces or removes blank lines, and fixes odd and zero-width spaces.
- Shows how many characters were removed, with file open and download.
Before and after: leading, trailing and inner spaces
In this table a middle dot stands for a space and an arrow for a tab, so you can see what each setting removes. The collapse option is on in the last column only. Notice that collapsing never touches the tab at the start of a line, and that Trailing only keeps both the tab and the leading spaces, which is why it suits code.
| Input line | Both ends | Leading only | Trailing only | Both ends plus collapse |
|---|---|---|---|---|
| ···Leading spaces | Leading spaces | Leading spaces | ···Leading spaces | Leading spaces |
| Trailing spaces····· | Trailing spaces | Trailing spaces····· | Trailing spaces | Trailing spaces |
| →A tab and···double···spaces·· | A tab and···double···spaces | A tab and···double···spaces·· | →A tab and···double···spaces | A tab and double spaces |
| ··Both ends padded·· | Both ends padded | Both ends padded·· | ··Both ends padded | Both ends padded |