Text · measure length · Nov 2026

The LEN function,
measured & explained.

Syntax, a live playground, a measured length gallery, the spaces-count trap, and a sourced error library: measuring text length.

D1
fx
=LEN(A2)
0
measured gallery rows
0
sourced errors fixed
0
platforms checked
// 01 — Anatomy

How LEN works

Returns the number of characters in text. Spaces count; an empty string is 0.

=LEN(text)
textThe string to measure.
counts allSpaces and punctuation count as characters.
vs LENBLEN counts characters; LENB counts bytes.
.bool-moat td.res-text{color:var(--cyan);font-weight:700;font-family:var(--mono)}
// 02 — Measure length

What LEN actually counts

LEN returns the number of characters in a text string — every character, including spaces and punctuation. Every row was measured live in HyperFormula. Click any row to load it.

Length gallery — counts every character, spaces included

ExpressionResultWhy
=LEN(A2)5Excel has 5 characters
=LEN(A3)7Formula has 7
=LEN(A4)6Lookup has 6
=LEN(A5)3Lab has 3
=LEN("a b")3The space counts
=LEN("")0Empty string is 0
=LEN(A2&"!")6Concatenation adds 1
=LEN(12345)5Numbers count their digits

Two useful LEN tricks

ExpressionResultWhy
=LEN(TRIM(" hi "))2TRIM first to ignore padding spaces
=LEN(A2)-LEN(SUBSTITUTE(A2,"e",""))1Count occurrences of a character
⚠ LEN counts spaces and punctuation. Leading and trailing spaces inflate the count — wrap in TRIM first. LEN counts characters; LENB counts bytes, so double-byte characters count as 2 there.
// 03 — Try it live

Interactive LEN playground

Edit the table or type any formula — the engine evaluates instantly. Load a preset to see LEN count spaces, return 0 for an empty string, and measure a concatenated string.

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 LEN works

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

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

Master text measurement

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

  • LEN / LENB — characters vs bytes
  • The spaces-count trap and the TRIM fix
  • Counting occurrences with SUBSTITUTE
  • LEN + LEFT/RIGHT/MID for dynamic slices
Free while in beta
Browse the function library

No account needed. Every page has a live playground.

// 07 — FAQ

Frequently asked