Collapse Whitespace

Turn a pasted passage into a single line with regular spacing.

Text inputPreview and copyRuns in your browser

Enter your text

Result

How to use

  1. Paste the text to normalize and inspect the result before using it in a preformatted destination.
  2. Select Convert to generate the output.
  3. Review the output before copying it.

How it works

Turn a pasted passage into a single line with regular spacing. Replace every consecutive whitespace run with one ordinary space, then remove outer whitespace.

Formula or processing rules

Replace every consecutive whitespace run with one ordinary space, then remove outer whitespace.

Worked example

Extra spaces and a line break become single spaces between alpha, beta, and gamma.

Example text lengths in UTF-16 code units
Input · 20
Output · 16
Worked example
MeasureValue
Source textalpha beta gamma
Resultalpha beta gamma

Pros and cons

Pros

Turn a pasted passage into a single line with regular spacing. The sample provides an immediate check of the expected output.

Cons

This changes line breaks and tab spacing. Use Trim Whitespace from Lines if the rows should stay separate.

Limitations and troubleshooting

If you only want to remove spaces at each line’s edges, choose Trim Lines instead.

Remove edge whitespace only

Frequently asked questions

Can I use this on aligned text or code?

Whitespace can carry meaning in some code and preformatted columns. Keep a copy and only normalize prose or text where spacing is incidental.

What rule does the Collapse Whitespace apply?

Replace every consecutive whitespace run with one ordinary space, then remove outer whitespace.

What should I see in the Collapse Whitespace example?

Extra spaces and a line break become single spaces between alpha, beta, and gamma.

What should I verify after using Collapse Whitespace?

This changes line breaks and tab spacing. Use Trim Whitespace from Lines if the rows should stay separate.

Is my input stored by the tool?

The transformation is computed in the open page. The tool does not save the submitted text.