WorkbookLogic
FunctionTextbeginnerTRIMSUMPRODUCTIF

TRIM Function

By WorkbookLogic

The Excel TRIM function removes leading and trailing standard spaces and reduces repeated standard spaces between words to one. It does not remove every Unicode whitespace character.

ExcelLast reviewed Sep 11, 2026
trim-function-v1.0.0.xlsx
Excel TRIM Function
TRIM removes leading, trailing, and repeated standard spaces from text.
Text scenarios, editableTRIM examples
ScenarioSource textData noteExpectedExampleFormula syntaxResult
Outer spaces Maya Chen Leading and trailingMaya ChenOuter spaces=TRIM(B12)Maya Chen
Repeated middleNorth RegionThree spaces become oneNorth RegionRepeated middle=TRIM(B13)North Region
Mixed spaces Q3 2026 Outer and internalQ3 2026Mixed spaces=TRIM(B14)Q3 2026
Already cleanAlready cleanNo changeAlready cleanAlready clean=TRIM(B15)Already clean
Empty textRemains emptyEmpty text=TRIM(B16)
How TRIM behaves
TRIM removes leading and trailing standard spaces.
Repeated standard spaces between words are reduced to one.
Non-breaking spaces copied from web pages may require SUBSTITUTE or CLEAN first.
Reliability checks
All five TRIM results match the visible expected textOK
Already-clean text remains unchangedOK

Overview

The Excel TRIM function normalizes standard spaces in text. It removes spaces at the beginning and end and reduces repeated spaces between words to a single space.

Quick reference

Syntax: =TRIM(text)

Returns: Text without leading or trailing standard spaces and with single spaces between words. (text)

Arguments:

  • text (required) — The text value or cell reference from which extra standard spaces should be removed.

TRIM has one required text argument and no optional settings. It returns text with standard ASCII spaces normalized, rather than validating every kind of invisible character.

Common uses

  • Clean imported names, labels, descriptions, and lookup keys.
  • Prevent failed matches caused by leading or trailing spaces.
  • Normalize user-entered text before comparison or validation.
  • Prepare text for length checks and case standardization.

Calculations

TRIM processes ordinary space characters. It removes every leading and trailing standard space and changes each run of internal standard spaces to one.

Already-clean text is returned unchanged, and blank or empty text remains empty. The function returns a cleaned value in its formula cell; it does not alter the original source.

Web pages and external systems may contain non-breaking spaces or other Unicode whitespace. Those characters can look like ordinary spaces but survive TRIM. SUBSTITUTE, sometimes combined with CLEAN, is needed when the source contains a different character.

Function behavior

Situation

Behavior

Leading standard spaces

Removed.

Trailing standard spaces

Removed.

Repeated internal standard spaces

Reduced to one.

Already-clean text

Returned unchanged.

Blank or empty text

Returns empty text.

Non-breaking spaces

May remain because they are not ordinary space characters.

Common errors

Expecting TRIM to remove every kind of whitespace

What happens:
Copied web text still contains blank-looking characters after cleaning.

Better approach:
Identify the character and replace it with SUBSTITUTE; use CLEAN when nonprinting control characters are also present.

Expecting the source cell to change

What happens:
The original text remains unchanged because TRIM returns a separate formula result.

Better approach:
Use the cleaned result downstream, or deliberately replace the source after reviewing the output.

Removing intentional repeated spaces

What happens:
Spacing used for a special layout or code is collapsed.

Better approach:
Apply TRIM only when ordinary word spacing is the intended structure.

Example

Example 1 — Remove Outer Spaces

=TRIM(B12)

The source contains spaces before and after Maya Chen. The result is Maya Chen without the outer spaces.

Example 2 — Reduce Repeated Internal Spaces

=TRIM(B13)

North and Region are separated by three standard spaces. TRIM reduces them to one and returns North Region.

Example 3 — Normalize Mixed Spacing

=TRIM(B14)

The source has both outer spaces and repeated internal spaces. The result is Q3 2026.

Example workbook

The workbook contains TRIM Example and Notes tabs. Five formulas demonstrate outer spaces, repeated internal spaces, mixed spacing, clean text, and empty text. Two checks validate all expected results and the unchanged clean value.

Key takeaway

TRIM normalizes ordinary spaces; identify and replace non-breaking or other special whitespace separately.