Skip to content
Text

Remove extra spaces, tabs and blank lines

Tidy extra spaces and blank lines in text copied from a document, spreadsheet or web page. Choose which cleanup rules to apply, then compare the result before using it.

Runs in your browser — your input is not uploaded to ToolsNow.

Input
0 chars0 words0 lines
Result
0 chars0 words0 lines

How to use

  1. Paste the text. Keep the original available if indentation or spacing has meaning in the document.
  2. Choose the cleanup rules. Trim each line, Collapse repeated spaces and Collapse blank lines start on. Turn off anything you need to preserve.
  3. Check and copy. Review paragraph breaks and alignment in Result, then use Copy result or Download. Remove all whitespace also deletes line breaks, so leave it off for prose.

Questions

Why do two spaces that look identical behave differently?

One may be a non-breaking space, U+00A0, which prevents a line wrapping there. This tool always converts it and several other Unicode spaces to ordinary spaces, even with all toggles off. Line endings are also normalised; this is not a byte-for-byte preservation tool.

Should I collapse blank lines or remove them?

Collapse blank lines keeps one empty line between paragraphs. Remove blank lines deletes the empty lines but leaves the text on separate lines. A line containing spaces becomes empty when Trim each line is enabled.

Can I use it on source code?

The default rules can remove indentation or change spaces inside string literals. Tabs → 2 spaces is also a text replacement, not a code-aware formatter, and tabs are required in some formats. Use a formatter for your language when spacing affects the meaning.

What does Remove all whitespace do?

It removes spaces, tabs and line breaks, so "AB 12" becomes "AB12". This can help with a copied serial number, but it also joins ordinary words and can change a key or identifier if its spaces were intentional.

Examples and checks

Tidy spaces in text copied from a PDF, spreadsheet or web page. Try trimming the ends of lines first, then remove extra spaces or blank lines if needed.

Clean a line

Input or situation
red apple
Result
red apple

With Trim each line and Collapse repeated spaces enabled, the ends are trimmed and the three internal spaces become one.

Keep paragraph boundaries

Input or situation
First paragraph Second paragraph
Result
First paragraph Second paragraph

Collapse blank lines keeps one empty line between paragraphs. Remove blank lines removes that separator completely.

Before you use the result

Published by ToolsNow. How tools and sources are checked · Report a problem

Related tools