Excel TRIM Function

TRIM removes leading and trailing spaces and reduces repeated spaces between words to a single space.

Use it to clean imported text, names, codes, categories, or lookup keys before comparing, joining, counting, or filtering values.

1
Choose text The value that may contain spaces
2
Remove edge spaces Leading and trailing spaces are removed
3
Collapse inner spaces Repeated regular spaces become one

TRIM syntax & arguments

Syntax

=TRIM(text)
Required Optional
  1. 1

    text

    Required

    The text value, cell reference, or formula result to remove extra spaces from.

Example

=TRIM(A2)

Remove leading, trailing, and repeated spaces from the text in A2.

TRIM caveats

TRIM fixes many common spacing problems, but not every invisible character is a normal space.

  • It only removes certain space characters

    TRIM handles regular spaces, but all nonbreaking spaces, tabs, and line breaks are preserved.

  • Repeated intentional spaces are collapsed

    TRIM keeps only one regular space between words, even if repeated spaces were meaningful in the original text.

  • Cleaned numbers are still text

    TRIM returns a text result. If the cleaned value needs to be numeric, convert it after cleaning.

Building clean labels? Use TRIM before CONCATENATE so accidental source spacing does not carry into the final string.

Intro TRIM practice problems

No intro TRIM problems are currently available.

Advanced TRIM practice problems

Use TRIM alongside other Excel functions in realistic, less-prescriptive challenges.