Text · clean up spaces · Nov 2026

The TRIM function,
measured & explained.

Syntax, a live playground, a measured space-cleaning gallery, the tab and non-breaking-space traps, and a sourced error library: normalizing text spacing.

D1
fx
=TRIM(" Hello World ")
0
measured gallery rows
0
sourced errors fixed
0
platforms checked
// 01 — Anatomy

How TRIM works

Removes extra spaces from text: strips the ends and reduces internal runs to a single space. Only the ASCII space (32) is affected.

=TRIM(text)
textThe string to clean.
endsLeading and trailing spaces are removed.
internalRuns of internal spaces collapse to one.
.bool-moat td.res-text{color:var(--cyan);font-weight:700;font-family:var(--mono)}
// 02 — Clean up spaces

What TRIM actually removes

TRIM strips leading and trailing spaces and reduces every internal run of spaces to a single space. It does not touch tabs or non-breaking spaces. Every row was measured live in HyperFormula. Click any row to load it.

Space-cleaning gallery — one internal space survives

ExpressionResultWhy
=TRIM(" Hello World ")Hello WorldStrips ends and collapses internal runs to one space
=TRIM(" Excel ")ExcelLeading and trailing spaces removed
=TRIM("a b c")a b cSingle internal spaces are kept
=TRIM(A2)ExcelAlready-clean text is unchanged
=TRIM(" ")All-space input becomes an empty string
=TRIM(A2&" ")ExcelTrims spaces appended to a cell
=LEN(TRIM(" hi "))2Measure length after trimming
=TRIM("Excel Formula")Excel FormulaThe single space between words survives

What TRIM leaves alone

ExpressionResultWhy
=TRIM("a b")a bA tab (CHAR 9) is NOT a space — TRIM keeps it
=TRIM(" a ")aA single leading/trailing space is removed
⚠ TRIM only removes the ASCII space (character 32). It does NOT remove tabs, line breaks, or non-breaking spaces (CHAR 160) copied from the web. For those, SUBSTITUTE them to a normal space first, or wrap with CLEAN. TRIM keeps one space between words — it is not a remove-all-spaces tool.
// 03 — Try it live

Interactive TRIM playground

Edit the table or type any formula — the engine evaluates instantly. Load a preset to see TRIM collapse runs, strip the ends, keep one internal space, and measure length after cleaning.

A1Sample data — click any cell to edit, the formula re-evaluates live
Result
—
✓ readyHyperFormula 3.5
// 04 — Error library

The real-world error library

8 failure patterns mined from actual user reports on Reddit, Stack Overflow and Super User — each with the authentic symptom, root cause, a fix, and a runnable formula. Not textbook theory.

// 05 — Cross-platform

Where TRIM works

TRIM is available across modern Excel, Google Sheets and LibreOffice. It has been in Excel since 2003.

PlatformSupportNotesGotcha
✓ Supported full TRIM◐ Partial works with caveatsCompiled from public docs · verify against your build
// Go deeper

Master text cleaning

TRIM is one piece. The full course walks the toolkit end to end with live, measured examples.

  • TRIM vs CLEAN — spaces vs control characters
  • The non-breaking-space (CHAR 160) trap
  • Removing tabs and line breaks before trimming
  • TRIM + VALUE + PROPER for clean, typed data
Free while in beta
Browse the function library

No account needed. Every page has a live playground.

// 07 — FAQ

Frequently asked