← All how-to recipes

How to remove extra spaces from text

✓ Verified in LibreOffice 25.8.7.3

Strip leading, trailing, and repeated internal spaces so text is clean and comparable.

The formula

AppFormulaNotes
Excel=TRIM(A2)Removes leading/trailing spaces and collapses internal runs to one.
Google Sheets=TRIM(A2)Identical.
LibreOffice Calc=TRIM(A2)Identical.

How it works

TRIM removes every space from the start and end, and reduces any run of spaces between words to a single space. ' hello world ' becomes 'hello world'. Combine with CLEAN() to also strip non-printing characters.

Verified, not just documented

We ran =TRIM(A2) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned hello world — exactly the expected result. Every formula here is confirmed by actually executing it.