How to remove spaces from the start and end of each line
Copyable sample text
Trim mode: both, left or right
What the tool changes and what it keeps
Copy the result or download it as a .txt file
Features explained
Trim each line
Removes whitespace from the edges of every line, one line at a time.
Trim mode: both (default)
Removes spaces and tabs at the start and at the end of each line.
Trim mode: left
Removes whitespace only at the start of each line, such as indentation.
Trim mode: right
Removes whitespace only at the end of each line, such as invisible trailing spaces.
Copy result to clipboard
One click copies the trimmed text. The button changes to Copied! so you know it worked.
Download as .txt
Saves the result as a plain text file, useful when you want to keep it.
Load example
Fills the input with sample text so you can see how each Trim mode works before you use your own.
Clear and reset
The Clear button empties the tool so you can start with new text.
Runs in the page
Text is processed with JavaScript in the page. No request to a server was found in the tool code.
What can you use it for?
Remove trailing spaces from lines
Set Trim mode to right to clean invisible spaces at the end of lines in code, notes or logs.
Remove indentation from copied text
Set Trim mode to left to take away spaces and tabs at the start of each line, for example in text copied from a PDF or an email.
Clean lists before you use them
Trim a list of names, IDs or emails so that stray spaces do not break a comparison or an import.
Tidy pasted text from spreadsheets
Clean cells copied from a spreadsheet that carry extra spaces around the values.
Prepare text for forms and code
Remove extra edge spaces from each line before you paste the text into a form, a config file or a script.
Tool information
| Tool type | Line trimmer (remove whitespace at the edges of each line) |
|---|---|
| Input | Plain text, pasted or typed in the Input text box |
| Option | Trim mode |
| Trim mode values | both, left, right |
| Trim mode default | both |
| Output | Trimmed lines joined with line breaks, in the Result box |
| Copy | Copy result button |
| Download format | .txt (plain text) |
| Processing | In the page with JavaScript (client-side) |
Benefits
- Cleans every line in one step instead of line by line.
- Three trim modes let you remove only the side you need.
- Words and spaces inside a line stay as they are.
- Copy or download the result in one click.
- Works in the browser page, with nothing to install.
Limitations
- It works with plain text. The code shows no file upload, so paste your text into the box.
- It trims only the edges of each line. It does not remove extra spaces between words inside a line.
- It does not remove empty lines or change the order of lines.
- Trim mode is its only option.
- The download is a .txt file only.
Privacy
This tool processes your text in the page using JavaScript, and no network request was found in the tool code. Even so, do not paste confidential information such as passwords or private data.
Tips
- Use Load example first to see how the result looks.
- Choose right if you want to keep indentation and only clean the end of each line.
- Choose left if you want to remove indentation and keep the end of each line.
- Press Clear before you paste new text so old text does not stay in the tool.
Frequently asked questions
How do I remove spaces from the start and end of each line?
Paste your text into the Input text box and keep the Trim mode on both, which is the default. Every line is trimmed and the cleaned text appears in the Result box.
How do I remove leading spaces from every line?
Set Trim mode to left. It removes the whitespace at the start of each line and leaves the end as it is.
How do I remove trailing spaces from every line?
Set Trim mode to right. It removes the whitespace at the end of each line and keeps the start, so indentation stays.
Does this remove spaces between words?
No. It trims only the edges of each line. Spaces between words inside a line stay the same.
Does the tool remove empty lines?
No. It trims each line and does not delete lines. Its only job is to remove whitespace at the edges.
Does it remove tabs too?
Yes. Trimming removes whitespace at the edges of a line, which includes spaces and tabs.
Can I download the trimmed text?
Yes. Press Download .txt to save the result as a plain text file.
Is my text uploaded to a server?
The tool processes text in the page with JavaScript, and no network request was found in the tool code. Still, avoid pasting confidential information.