Text
TRIM function playground
Removes extra spaces from text, leaving single spaces between words.
The playground runs in your browser. Nothing you type is sent anywhere.
How TRIM works
TRIM deletes every space at the start and end of the text, and squeezes runs of spaces between words down to one.
The City column has extra spaces that are hard to see. LEN shows the difference: compare LEN(D2) with LEN(TRIM(D2)).
Syntax
=TRIM(text)| Argument | What it means |
|---|---|
textrequired | The text or cell to clean. |
Examples
| Formula | What it does | Result |
|---|---|---|
=TRIM(D2) | Clean up the city name. | New York · Chicago · San Diego · Austin … |
=LEN(D2)-LEN(TRIM(D2)) | How many extra spaces were removed. | 5 · 2 · 3 · 0 … |
=TRIM(B2)&" "&TRIM(C2) | Clean each part before joining. | Grace Kim · Omar Haddad · Lily Chen · Jonas Berg … |
Common mistakes
Non-breaking spacesText copied from web pages can contain a special space (CHAR(160)) that TRIM doesn't remove. Use SUBSTITUTE to swap it for a normal space first.
Results are copiesTRIM returns cleaned text in a new cell; paste it as values to replace the original.
Related functions
Learn more
Download the example workbook (.xlsx)
The workbook has the same sample data and formulas, plus a practice sheet.