# TRIM in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/trim/

TRIM removes spaces at the start and end of a text and reduces repeated spaces inside it to one. Run it on imported or typed data before you use it as a lookup key.

## Syntax

```
TRIM(text)
```

## Arguments

- `text` (string, required: yes): The text to clean.

## Examples

The examples use this table, starting in A1:

| Name |
|---|
|   Ana   Pop   |
| Radu |
|   x  y |
|  42  |

```
=TRIM(A2)
```

Result: `Ana Pop`

Leading and trailing spaces go, and runs of spaces inside shrink to one. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=LEN(A2)
```

Result: `13`

Length before cleaning, for comparison. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=LEN(TRIM(A2))
```

Result: `7`

Length after cleaning. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=TRIM(A4)
```

Result: `x y`

Spaces inside the text are also reduced to a single space. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=ARRAYFORMULA(TRIM(A2:A5))
```

Result: 

| Ana Pop |
|---|
| Radu |
| x y |
| 42 |

Clean a whole column at once. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- TRIM does not remove the non-breaking space, CHAR(160), common in data pasted from web pages. Use SUBSTITUTE(A1, CHAR(160), " ") first.
- The result is text. TRIM(" 42 ") looks like a number but ISNUMBER says FALSE. Wrap it in VALUE when you need a number.
- It collapses spaces inside the text too, so it also changes text where double spaces were intended.

## Compared with Excel

Same syntax in Excel.

## Related functions

- [SUBSTITUTE](https://goingstellar.ro/reference/sheets/substitute/)
- [VALUE](https://goingstellar.ro/reference/sheets/value/)
- [LEN](https://goingstellar.ro/reference/sheets/len/)
- [REGEXREPLACE](https://goingstellar.ro/reference/sheets/regexreplace/)

## Sources

- [TRIM (Docs Editors Help)](https://support.google.com/docs/answer/3094140)

