Text Trimmer

Remove leading and trailing whitespace from text

Remove leading or trailing whitespace from each line.

Input

Output

About the Text Trimmer

Stray spaces at the start or end of a line are invisible but cause real problems: failed string comparisons, noisy diffs, broken indentation, and CSV values that do not match. The Text Trimmer removes that whitespace from every line at once.

Options

  • Remove leading spaces (left trim). On by default. Removes spaces and tabs at the start of each line. This also strips indentation, so turn it off for code where indentation matters.
  • Remove trailing spaces (right trim). Removes spaces and tabs at the end of each line, the kind that editors and git diffs flag.

Turn both on to clean each line completely.

Line by line

Unlike a plain trim, this works on each line separately and never joins lines or removes blank ones. To join lines together, use the Line Break Remover.

When it helps

  • Cleaning a list of values before pasting it into a spreadsheet or a SQL query.
  • Removing trailing whitespace before committing a file.
  • Fixing text copied from terminals, PDFs, and chat apps with ragged spacing.

Frequently asked questions

What does the Text Trimmer tool do?
The Text Trimmer removes unwanted leading (left) and trailing (right) whitespace from your text while preserving the content and line structure. You can choose to trim spaces from either or both sides.
How do I use the Text Trimmer?
Simply paste or type your text into the input field, then check the boxes for 'Remove leading spaces' or 'Remove trailing spaces' based on your needs. The trimmed result appears instantly in the output field.
Does it work on multi-line text?
Yes! The Text Trimmer processes each line individually, removing leading and/or trailing spaces from every line while preserving your text's line structure.
What types of whitespace does it remove?
The tool removes all types of leading and trailing whitespace characters including spaces, tabs, and other whitespace characters, depending on your selected options.