TextyConverterbeta
⌘K

Trim Trailing Whitespace

Remove trailing whitespace from every line — spaces and tabs that hide at the end. Browser-only.

0 characters
0 characters

About Trim Trailing Whitespace

This tool strips whitespace from the end of each line. It's a common cleanup operation for source code, where stray trailing spaces clutter diffs and trigger lint warnings.

When to use it

  • Cleaning code before committing to source control
  • Removing invisible spaces that break exact-match comparisons
  • Sanitizing terminal output where lines pad to a fixed width
  • Tidying hand-edited files before sharing

How it works

Each line is matched against /[ \t]+$/ 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

Does it touch leading whitespace?
No. Only trailing whitespace is removed.
Are tabs at end of line removed?
Yes. The regex matches both spaces and tabs at the end of each line.

Related tools