Trim Whitespace Tool
Remove spaces at the start and end of each line. You can also reduce repeated spaces and tabs within a line to a single space.
How to use Trim Whitespace Tool
1. Paste or type your text or list into the box. 2. Choose any options shown, then select Calculate. 3. Select Copy result to copy the answer. 4. Select Reset to clear the box and start again.
Why use this tool?
Clean pasted text before placing it in a form, a document or a spreadsheet. Line breaks remain, so separate lines are not joined into one paragraph.
How the calculation works
Trim each line; optionally collapse repeated internal spaces and tabs to one space. Text remains in the browser. Words are groups of letters or numbers. Apostrophes, hyphens and underscores stay inside a word. Character counts use Unicode code points, which can differ from visible symbols. Line breaks are retained. The optional switch does not join paragraphs or normalise every Unicode space inside lines.
Example
Worked example: Text = " one two \n three "; Collapse Repeated Internal Spaces = true. Result: one two three.
Practical tip
Leave repeated-space removal off when spacing has a purpose, such as an aligned plain-text table.
Frequently asked questions
Does this remove line breaks?
No. It trims each line while retaining the line breaks.
What does the repeated-spaces option change?
It reduces runs of ordinary internal spaces and tabs to one space. It does not join paragraphs or normalise every special Unicode spacing character.
How do I copy the result or start again?
Select Copy result after running the tool to copy the displayed answer. Reset clears the text and result, so keep a separate copy of any text you want to save.