Remove Extra Spaces

Trim horizontal whitespace and collapse runs of spaces while preserving line breaks.

Loading interactive controls…

Input

Results

Clean horizontal whitespace
Some extra spaces
Another line

How to use remove extra spaces

Trim horizontal whitespace and collapse runs of spaces while preserving line breaks.

Enter or paste your text, adjust any available options, then copy the result you need.

What to check before using the result

Indentation will be changed, so avoid using this on indentation-sensitive source code.

Related tools

Explore related tools and references