TRIM Function and Its Usage

Last Updated : 17 Feb, 2026

TRIM is a text-cleaning function used to remove extra spaces from text strings. TRIM keeps one space between words it does not remove all spaces between words.

The TRIM function:

  • Removes leading spaces (spaces before text)
  • Removes trailing spaces (spaces after text)
  • Reduces multiple spaces between words to a single space

Syntax:

=TRIM(text)

  • Parameter: text → The text string or cell reference containing extra spaces.

Step-by-Step: Using the TRIM Function

Step 1: Enter Text Data

  • Enter text values containing extra spaces in a column

Step 2: Select Result Cell

  • Select the cell where you want the cleaned (trimmed) result to appear.
trim
Text data

Step 3: Enter TRIM Formula

=TRIM(A1)

Step 4: Apply to Other Cells

  • Use the fill handle to copy the formula down the column.
trim_output
Data after applying TRIM

Limitation: TRIM removes only standard spaces (ASCII 32). It may not remove non-breaking spaces copied from websites or external systems.

Why TRIM is Important

TRIM is commonly used for:

  • Cleaning imported data from external systems
  • Fixing accidental typing spaces
  • Preparing data for lookup functions like VLOOKUP, MATCH, or EXACT
  • Standardizing datasets before analysis
Comment

Explore