Skip to content

Whitespace Trimmer

Trim and normalize whitespace in text instantly.

Trim options
Trimmed
Whitespace trimmed. Copy or download the result.

Whitespace Trimmer cleans up stray spaces, tabs, and inconsistent indentation from pasted text. Trim the outer edges of your text, trim every line individually, and optionally collapse repeated internal spaces—all instantly in your browser.

How it works

The tool always trims leading and trailing whitespace from the full text. Enable 'Trim each line' to also strip spaces at the start and end of every line, and enable 'Collapse internal spaces' to squeeze repeated spaces or tabs within a line into a single space.

Benefits

  • Fixes text pasted from spreadsheets, PDFs, or emails with stray whitespace
  • Optional per-line trimming for consistently formatted lists
  • Optional internal space collapsing for tidy single-spaced text
  • Live output with no upload step

Use cases

  • Cleaning spreadsheet cell values before importing them elsewhere
  • Normalizing pasted addresses or lists with inconsistent spacing
  • Preparing text for CSV or database import
  • Tidying up copy-pasted content before publishing

Best practices

  • Preview the output before pasting into indentation-sensitive code
  • Combine with Remove Empty Lines for a full text cleanup pass
  • Turn off line trimming if you need to preserve intentional indentation
  • Use collapse internal spaces sparingly on tabular or aligned text

Common mistakes

  • Trimming code samples that rely on leading whitespace for structure
  • Assuming this tool removes blank lines—it only trims whitespace
  • Forgetting that collapsing internal spaces also affects intentional multi-space alignment
  • Not checking output before overwriting an original document

Privacy

All trimming happens locally in your browser using JavaScript string operations. ToolHub does not receive or store your text.

Frequently asked questions

What whitespace does this tool remove?
It always trims leading and trailing whitespace from the whole text. With line trimming on, it also trims the start and end of every individual line.
What does 'collapse internal spaces' do?
When enabled, repeated spaces or tabs inside a line are collapsed down to a single space, which is useful for cleaning up text copied from spreadsheets or PDFs.
Will this remove blank lines?
No, blank lines are preserved by this tool. Use the Remove Empty Lines tool if you also want to strip blank or whitespace-only lines.
Does trimming affect tabs the same way as spaces?
Yes. Tabs and spaces are both treated as whitespace for trimming and, when enabled, for internal-space collapsing.
Can I trim only the outer whitespace and keep line indentation?
Yes. Turn off 'Trim each line' to keep each line's own leading and trailing spaces while still trimming the overall text's outer edges.
Is this tool safe for code snippets?
Use caution with indentation-sensitive code such as Python. Enabling 'Trim each line' removes leading indentation, which can change code meaning.

Version 1.0.0 · Updated 2026-07-27 · 30 seconds