LEN Function
The Excel LEN function returns the number of stored characters in text. Letters, digits, spaces, and punctuation all count, while a blank or empty text has length zero.
| Excel LEN Function | |||||||
| LEN counts every character in text, including spaces and punctuation. | |||||||
| Text scenarios, editable | LEN examples | ||||||
| Scenario | Source text | Data note | Expected | Example | Formula syntax | Result | |
| Single word | Workbook | Eight letters | 8 | Single word | =LEN(B12) | 8 | |
| Name with space | Maya Chen | Space is counted | 9 | Name with space | =LEN(B13) | 9 | |
| Empty text | Zero characters | 0 | Empty text | =LEN(B14) | 0 | ||
| Outer spaces | A | Both spaces count | 3 | Outer spaces | =LEN(B15) | 3 | |
| Identifier | Q3-2026 | Hyphen counts | 7 | Identifier | =LEN(B16) | 7 | |
| How LEN behaves | |||||||
| LEN counts letters, numbers, punctuation, and every visible or hidden space. | |||||||
| Empty text has a length of zero. | |||||||
| Clean text with TRIM first when surrounding or repeated spaces should not count. | |||||||
| Reliability checks | |||||||
| Every displayed LEN result matches the visible expected count | OK | ||||||
| Empty text returns a zero character count | OK | ||||||
Overview
The Excel LEN function counts every character stored in a text value. The count includes letters, digits, spaces, and punctuation rather than only visible alphabetic characters.
Quick reference
Syntax: =LEN(text)
Returns: An integer representing the number of characters. (integer)
Arguments:
text(required) — The text value or cell reference whose characters should be counted.
LEN has one required argument and no optional settings. The text may be supplied directly or by reference; spaces and nonprinting characters still contribute to the returned count.
Common uses
- Validate identifiers, account codes, or imported fields against length rules.
- Detect leading, trailing, or repeated spaces.
- Calculate character counts for
LEFT,RIGHT, orMIDlogic. - Distinguish true empty content from strings containing hidden characters.
Calculations
LEN reads the stored value and returns its character count. Every space and punctuation mark occupies one character position. A blank cell or empty string returns 0.
Leading and trailing spaces may be difficult to see but still increase the result. This makes LEN useful for detecting hidden content and validating fixed-length fields.
When the input is numeric, Excel counts the characters in its text representation rather than the formatted display. Number formatting such as commas, currency symbols, or decimal display settings is not necessarily part of the counted value.
Function behavior
Situation | Behavior |
|---|---|
Blank or empty text | Returns |
Internal spaces | Count as characters. |
Leading or trailing spaces | Count even when difficult to see. |
Punctuation | Each punctuation mark counts. |
Numeric input | Counts the text representation, not visual width. |
Error value | The error propagates. |
Common errors
Assuming LEN ignores spaces
What happens:
The result is larger than the visible letters suggest.
Better approach:
Inspect the source for leading, trailing, repeated, or non-visible characters.
Confusing character count with visual width
What happens:
Two strings that occupy similar screen space are expected to have the same length.
Better approach:
Remember that LEN counts stored characters, not rendered width.
Applying a business rule before cleaning text
What happens:
Extra spaces cause valid-looking values to fail a length check.
Better approach:
Normalize the text first when the rule is intended to evaluate cleaned content.
Example
Example 1 — Count a Single Word
=LEN(B12)
Workbook contains eight letters, so the result is 8.
Example 2 — Count an Internal Space
=LEN(B13)
Maya Chen contains eight letters and one space, producing 9.
Example 3 — Count Empty Text
=LEN(B14)
The source contains no characters, so LEN returns 0.
Example workbook
The workbook contains LEN Example and Notes tabs. Five examples count a word, a name with a space, empty text, outer spaces, and an identifier containing a hyphen. Two checks validate all displayed counts and the zero-length example.
Key takeaway
LEN counts stored characters—including spaces and punctuation—so it can reveal content that visual inspection misses.