Skip to content
NMSnabbit.

Trim Text & Whitespace

Trim each line and collapse extra spaces into single spaces.

Text Tools Runs in your browser

What does trimming text do?

Copy from a PDF and you often get lines padded with spaces at both ends, plus doubled gaps between words. NMSnabbit’s trim fixes the lot in one pass: each line loses its leading and trailing whitespace, interior runs of spaces or tabs collapse to one, and the block as a whole is trimmed. Line breaks themselves stay where they are.

How to use the Trim Text

  1. 1 Paste the text with uneven spacing.
  2. 2 Leading and trailing whitespace comes off every line.
  3. 3 Double and triple spaces inside lines squeeze down to one.
  4. 4 Copy the evenly spaced text back to where it came from.

What you can use it for

  • Cleaning copy-pasted text with ragged spacing.
  • Normalising spacing before a diff or import.
  • Fixing indentation pasted from a document.
  • Tidying user input from a form.

Frequently asked questions

Will “two spaces” inside a sentence become one?
Yes. Any run of spaces or tabs within a line collapses to a single space, in addition to the edge-trimming at each line’s start and end.
Does trimming rearrange or delete my lines?
No. It works within each line, so your lines keep their order, and interior blank lines survive — just emptied of stray spaces.
What should I use if the blank lines should go as well?
Chain the tools: trim first, then feed the result to Remove Empty Lines. The pair turns messy pasted text into a tight, uniform block.

Related tools

More Text Tools

More tools like this:

All Text Tools