Excel LEN Function (Text Length) – Examples & Practice
Practice the Excel LEN function online with an interactive grid, instant feedback, and clear formula help.
Instruction
Count total characters in cell A2, including spaces.
Formula Syntax
=LEN(text)
- text: The text whose length you want.
What it does
LEN returns the number of characters in a text string. It is commonly used for validation and parsing guardrails.
Excel LEN Function Examples
Count characters
=LEN(A2)
Returns total length including spaces.
Length after cleaning
=LEN(TRIM(A2))
Measures length once stray spaces are removed—closer to what humans perceive as “real” length.
Simple max-length validation
=IF(LEN(A2)<=10, "OK", "Too long")
Flags rows that exceed a character budget (tune the limit for your field rules).
text-cleanup.xlsx
| A | B | |
|---|---|---|
| 1 | Raw Text | Helper |
| 2 | ACME Corporation | ACME |
| 3 | Invoice-2026-0001 | 2026 |
| 4 | VIP_CLIENT | VIP |
| 5 | John Doe | Doe |
| 6 | Product Name | Product |
| 7 | Output |
Input Formula
Need Help?
Tips
- Wrap user input with TRIM before LEN checks.
- Watch for non-breaking spaces from web copy/paste.
- Pair LEN with IF for friendly validation messages.
LEN Function Use Cases
- Validate minimum/maximum field lengths
- Detect padded IDs that should be fixed width
- QA imported CSV strings
- Combine with LEFT/RIGHT/MID for parsing guards
- Monitor tweet-like short text constraints
Common mistakes - LEN function not working
- Expecting LEN to ignore spaces
- Using LEN on dates without understanding serial display vs text
- Forgetting invisible characters
- Confusing character count with byte count in international data
- Using LEN alone without TRIM for user input
FAQ
Does LEN count spaces?
Yes. Spaces are characters.
LEN vs LENB?
LENB counts bytes for double-byte character sets.
Does LEN work on numbers?
Numbers are evaluated as their text form in typical coercion paths—test with your version.
Can LEN validate input length?
Yes, often paired with IF for form-like checks.
Why is LEN larger than expected?
Hidden spaces, non-breaking spaces, or formatting artifacts—use TRIM and CLEAN.
Comparison
| Function | Measures |
|---|---|
| LEN | Characters |
| LENB | Bytes (DBCS) |
Example
=LEN("abc") returns 3.
Advanced examples
LEN with SUBSTITUTE counting
Repeat SUBSTITUTE to count occurrences of a delimiter by comparing lengths before and after removal.