Trim Leading & Trailing Spaces
Remove whitespace from the start and end of every line, without touching spaces inside the text.
About this tool
Remove whitespace from the start and end of every line, without touching spaces inside the text.
Example
Input: hello world
Output: hello world
How to use
Paste or type your text into the box above, then read or copy the result. Everything runs privately in your browser, your text is never uploaded to a server.
How to use this tool
- Paste or type your text into the input box.
- Choose the option to trim spaces from each line.
- Review the cleaned text in the output area.
- Copy the result and use it in your file, message, or code.
Step by step, what happens
- The tool reads your text line by line, not as one single block.
- For each line, it removes whitespace only from the start and the end.
- It leaves spaces, tabs, and other characters inside the line unchanged.
- The cleaned lines are then shown back to you as the output.
Worked example
If a pasted note has extra spaces around each line, this tool cleans them without changing the words inside the lines.
Input: apple pie
banana split
cherry tart
- The first line has spaces before and after the words, so those are removed.
- The second line has tabs around the text, so those are removed too.
- The third line loses only the spaces at the start, while the words stay the same.
Output: apple pie
banana split
cherry tart
Tips and common mistakes
- This tool trims each line separately, so it is useful for pasted lists and multi line text.
- It does not remove spaces between words, so internal formatting stays intact.
- If a line seems unchanged, check whether the extra spacing is inside the line rather than at the edges.
- Tabs count as whitespace, so they are removed from the start and end of a line too.
Frequently asked questions
What is trimmed?
Spaces and tabs at the beginning and end of each line are removed.
Are inner spaces kept?
Yes, only the edges of each line are trimmed.
Does it remove blank lines?
No, empty lines remain; use Remove Empty Lines for that.
More Text Tools Tools
Explore related calculators in this category
Remove Extra Spaces
Remove extra and double spaces from text, leaving single spaces between words.
Add Prefix / Suffix
Add a prefix and/or suffix to every line of your text instantly.
Add Text to Beginning, Free Online Text Tool
Add custom text to the beginning of every line in your text instantly. Get instant results, the formula, and a clear example.
Add Text to End
Add custom text to the end of every line in your text instantly.
You Might Also Like
Popular tools from other categories
.htaccess Generator
Generate common .htaccess rules, force HTTPS, www redirect, and caching, with checkboxes.
1031 Exchange Calculator - Free Online
Free Calculate tax deferral in a 1031 exchange. Step-by-step solutions and formulas included. Fast, accurate, and free, with formula and example.
4% Rule Calculator
Find the retirement nest egg you need using the 4% safe-withdrawal rule.
70% Rule Calculator
Calculate max offer using the 70% rule for flips.
Can't Find the Right Calculator?
Try our AI Math Solver, type any problem in plain English and get instant step-by-step solutions.