Free online text tool

Trim Text

Trim Text removes extra spaces from the beginning and end of every line. Paste your lines, click the button and copy the clean result. It is free and runs in your browser.

Trim Text

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Trim Text Example

Before
  apple  
   banana
 cherry   
After
apple
banana
cherry

Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.

Suggest a New ToolProvide Feedback on This Tool

What does Trim Text do?

This tool trims each line of your text. It removes the extra spaces and tabs at the beginning and at the end of every line, so all your lines start and end with a real character.

The words in a line and the spaces between them are not changed. Empty lines stay where they are, and a line that only has spaces becomes an empty line.

Use it to clean up text copied from a PDF, an email or a web page, or a list where the lines have uneven indents.

Trim text examples

Each example shows the lines before and after trimming. Leading and trailing spaces are removed, spaces between words are kept.

SettingBeforeAfter
Spaces at both ends
  apple  
   banana
apple
banana
Spaces between words stay
  hello    world  
hello    world
Tabs are trimmed too
		name	
name
Line with only spaces
a
    
b
a

b
Trim the start only
  keep end  
keep end  
Trim the end only
  keep start  
  keep start
Already clean
one
two
one
two

How to trim text

  1. 1
    Add your lines
    Type or paste your lines into the box, or import a text file.
  2. 2
    Choose what to trim
    Keep both options ticked to trim the start and the end of each line, or untick one.
  3. 3
    Click Trim Text
    Extra spaces at the edges of every line are removed at once. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the lines where you need them.

When to trim text

Good for

Cleaning lists copied from emails, PDFs and web pages, fixing uneven indents, and getting lines ready for sorting, comparing or importing into a spreadsheet.

Check first

Trimming only touches the edges of each line. Spaces between words stay, and empty lines stay. Use Undo right after if the result is not what you wanted.

Other tools

To also fix the spaces between words, try Remove Extra Spaces. To delete blank lines, try Remove Empty Lines.

Trim text FAQ

What does the Trim Text tool do?

It trims each line of your text. It removes extra spaces and tabs from the beginning and the end of every line and leaves the words and the spaces between them as they are.

How do I trim text?

Type or paste your lines, then click Trim Text. The trimmed lines replace the text in the box. Click Copy to use them, or Undo to go back.

Does it remove spaces between words?

No. Only the spaces at the start and the end of each line are removed. Spaces between words stay. To change those, use Remove Extra Spaces.

Can I trim only the start or only the end of a line?

Yes. Untick Trim the start of each line or Trim the end of each line, then click Trim Text. Both are ticked by default.

Does it remove tabs and other blank characters?

Yes. Tabs, non-breaking spaces and other blank characters at the edges of a line are removed along with normal spaces.

What happens to empty lines?

Empty lines stay in place. A line that only has spaces becomes an empty line. To delete empty lines, use Remove Empty Lines.

Is this tool free and is my text private?

Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.

Looking for more text tools?

Browse Modify Tools

Last updated: 2 November 2026