Whitespace Remover

Trim extra spaces, tabs, and blank lines.

Text copied from a PDF or an old document tends to bring along a mess of extra spaces, stray tabs, and blank lines you didn't ask for. This tool cleans that up: trim spaces from the start and end of each line, collapse doubled up spaces into one, or strip out blank lines entirely.

How to use it

  1. Paste your text into the box.
  2. Click trim each line to remove leading and trailing spaces.
  3. Click collapse multiple spaces to turn repeated spaces into one.
  4. Click remove blank lines to delete lines that are empty or just whitespace.
  5. Run more than one option in a row if you need to.
  6. Copy the cleaned result.

When it helps

  • Fixing spacing on text copied from a PDF, which often has odd line breaks.
  • Cleaning a code snippet before pasting it into an editor.
  • Preparing a list for a spreadsheet import where blank rows would cause problems.
  • Trimming trailing spaces from a script's output before displaying it.
  • Shrinking a document with too many blank lines before sharing it.

Good to know

  • Trim each line before collapsing multiple spaces if you need both, since trimming doesn't touch spaces in the middle of a line.
  • Be a little careful with remove blank lines in code, since intentional blank lines often make code more readable.
  • If the original spacing actually mattered, like in a table, check the result before you use it.
  • If you're cleaning text for a spreadsheet import, run remove blank lines last, after trimming and collapsing, so you don't leave near empty lines behind.
  • If you're preparing text to paste into a chat app that preserves formatting, collapse multiple spaces first so the message doesn't look oddly spaced out on the other end.

Questions

Does this remove tabs as well as spaces?

Yes, the collapse option treats tabs and spaces the same way, turning any run of either into a single space.

Does trimming affect spacing inside a line?

No. Trimming only touches the start and end of each line. Spacing in the middle stays the same unless you also use the collapse option.

Can I undo a cleanup if it doesn't look right?

There's no undo built in, so it's worth keeping your original text saved somewhere until you're happy with the result.

Will this remove non breaking spaces?

A non breaking space, often introduced by copying from a web page, may not always get caught by simple collapsing, so it's worth checking the result visually in tricky cases.

Can I clean whitespace inside code?

You can, but be careful with remove blank lines in code, since intentional blank lines often help readability. Trimming trailing spaces is generally the safest option there.

Does this work on text with mixed languages or scripts?

Yes, the whitespace operations don't depend on the language of the surrounding text, since they only look at actual space, tab, and line break characters.