Whitespace Remover

Trim every line, collapse runs of spaces and tabs into one space, and optionally drop blank lines.

Calculations happen locally. We do not send your values to our server.

Example

“ Extra spaces ” followed by a blank line and “ Another⇥line ” becomes two tidy lines: “Extra spaces” and “Another line”. A label row such as “Name:⇥⇥Alex” becomes “Name: Alex”.

Calculation method

Each line is trimmed at both ends, and any run of spaces or tabs inside a line becomes a single space. Blank lines are removed when the option is on and kept when it is off. Non-empty lines always stay separate, so a paragraph is never joined into one long line.

Important notes

Letters, numbers and punctuation are never changed — only whitespace is. Some special spaces, such as a non-breaking space inside a line, are not collapsed and may still need attention in a text editor.

What gets cleaned

Each line is trimmed at both ends, and any run of spaces or tabs inside a line becomes a single space. “ Extra spaces ” followed by a blank line and “ Another⇥line ” becomes two tidy lines: Extra spaces and Another line. Text copied from PDFs, spreadsheets, emails and web pages often carries double spaces, tabs between columns and indentation that looks invisible until it breaks a search, a comparison or an import. Letters, numbers and punctuation are never changed.

Keeping or removing blank lines

With “Remove blank lines” on, empty lines disappear and the remaining lines sit directly under each other, which is useful for lists. Turn it off to keep paragraph breaks: two indented lines separated by an empty line become a, an empty line and b. Non-empty lines always remain separate lines; the tool does not join a paragraph into one long line. Tabs between label and value are collapsed as well, so “Name:⇥⇥Alex” becomes “Name: Alex”, which is handy before pasting into a form.

When not to normalise whitespace

Some text depends on its spacing. Python code, YAML files, Markdown lists, poetry and fixed-width tables use indentation or aligned columns to carry meaning, and collapsing them can break the file or the layout. Tab-separated data will lose its columns because tabs become single spaces. Keep a copy of the original for these cases. Some special spaces, such as the non-breaking space inside a line, are not collapsed and may still need attention in a text editor.

Worked examples
InputResult
␠␠Extra␠␠␠spaces␠␠↵↵␠␠Another→line␠␠ · remove blank linesExtra spaces↵Another line
␠␠a␠␠↵↵␠␠b␠␠ · keep blank linesa↵↵b
Name:→→Alex↵City:␠␠␠Paris · remove blank linesName: Alex↵City: Paris
→Indented↵␠␠␠␠code · remove blank linesIndented↵code

Frequently asked questions

Why does text copied from a PDF need this?

Because PDFs, spreadsheets, emails and web pages carry double spaces, tabs between columns and indentation that stays invisible until it breaks a search, a comparison or an import. Cleaning the whitespace first is what makes those later steps match reliably.

Should I keep blank lines?

Keep them when paragraph breaks matter: two indented lines separated by an empty line stay as a, an empty line and b. Remove them for lists, where the remaining lines then sit directly under each other and are easier to sort, deduplicate or paste into a form.

When should I not normalise whitespace?

When the spacing carries meaning. Python code, YAML files, Markdown lists, poetry and fixed-width tables rely on indentation or aligned columns, and collapsing them can break the file or the layout. Tab-separated data loses its columns because tabs become single spaces, so keep a copy of the original in those cases.

Related tools