Skip to content

Trim Lines

Remove the spaces and tabs at the start and end of each line of a list or block of text.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is Trim Lines?

Trimming works line by line: it strips whitespace at the beginning (left trim), at the end (right trim) or both, and leaves the line breaks alone. It fixes copied lists with stray indentation, trailing spaces that break comparisons and sloppy exports.

Choose which side to trim, and optionally collapse runs of spaces inside each line into one. Indentation is removed only when you ask for it, so trimming only the trailing side keeps code-style indentation intact.

How does it work?

  1. Paste the lines you want to clean.
  2. Select trimming on both ends, at the start only, or at the end only.
  3. Tick "collapse repeated spaces inside lines" if needed, then copy the result.

Common use cases

  • Removing trailing spaces from code or configuration before committing.
  • Cleaning a list of values pasted from a spreadsheet before deduplicating it.
  • Stripping indentation from copied Markdown or e-mail text.
  • Normalizing lines before comparing two texts.

Examples

Try this input in the tool above:

Input
   indented line   
	Tabbed	
  many    inner   spaces   
clean
Output
indented line
Tabbed
many    inner   spaces
clean

Privacy

Trim Lines runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Only whitespace at the ends (and optionally repeated inner spaces) is affected. Empty lines stay in place; use Remove Empty Lines to delete them.

Frequently asked questions

How is this different from Remove Extra Spaces?

Trim Lines is focused on line boundaries and lets you choose the left or right side. Remove Extra Spaces is a broader whitespace cleaner with blank-line and punctuation options.

Are tabs and non-breaking spaces trimmed?

Yes. Tabs, non-breaking spaces and other Unicode whitespace at line ends are removed.

More tools in Text Tools →