Trim Text

Remove spaces and tabs from the beginning and end of each line, while leaving the spacing inside lines alone.

Tip: press Ctrl + Enter to run.

About the Trim Text

Trailing spaces are invisible, but they cause real problems. “London ” and “London” look the same to a person but not to a spreadsheet, a database or a script. Leading spaces and tabs from copied code or indented lists can also break imports.

This tool trims each line separately. The spacing between words inside a line is not changed. If you also want to collapse double spaces inside lines, use Remove Extra Spaces.

How to use it

  1. Paste your lines into the input box.
  2. Click Trim Lines.
  3. Copy the trimmed result.

Example

Input
    indented line
trailing spaces here    
	 tabbed  and   spaced 	
Result
indented line
trailing spaces here
tabbed  and   spaced

When to use it

  • Cleaning spreadsheet columns before matching or looking up values.
  • Removing indentation from copied code or quotes.
  • Preparing tags, keywords or IDs for import.
  • Fixing lines that fail comparisons because of hidden spaces.

Frequently asked questions

Does trimming remove blank lines?

No. Blank lines stay, but any spaces on them are removed. Use Remove Empty Lines to delete them.

Is the space between words changed?

No. Only whitespace at the very start and end of each line is removed.

What is the difference from Remove Extra Spaces?

Trim Text only touches the edges of each line. Remove Extra Spaces also collapses repeated spaces inside lines.

Is the text I enter kept private?

Yes. The Trim Text runs entirely in your web browser, so your text is never uploaded to or stored on our servers. Like most free websites, TextForge shows ads from Google, which may use cookies. See our Privacy Policy for details.