TextyConverterbeta
⌘K

Trim All Whitespace

Remove leading and trailing whitespace from every line in one pass. Browser-only.

0 characters
0 characters

About Trim All Whitespace

This combines leading and trailing whitespace removal: every line gets both its start and end stripped. Inner whitespace (the spaces between words) is preserved. It's the per-line equivalent of Python's str.strip().

When to use it

  • Cleaning up a list where each line has random extra padding
  • Normalizing lines for exact-match comparison
  • One-shot cleanup before processing further

How it works

Each line is matched against /^[ \t]+|[ \t]+$/g and the matching characters are removed. Lines are split on LF/CRLF and rejoined with LF.

Examples

   Hello   
  World	 
  Clean  
Hello
World
Clean

Frequently asked questions

Are inner spaces preserved?
Yes. Only leading and trailing whitespace on each line is removed; spaces between words are untouched. To collapse multiple inner spaces, use remove-extra-spaces.
Does it remove blank lines?
Blank lines become empty (no content), but they're not removed. Use remove-empty-lines to drop them.

Related tools