LEN function
Counts the characters in a text string, including spaces, punctuation and invisible characters.
Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web
In every Excel versionWorks in Google Sheets
Syntax
LEN(text)| Argument | What it means | |
|---|---|---|
text | Required | The text, number or cell whose characters you want to count. |
Returns: A whole number: the count of characters (0 for an empty cell).
How LEN works
LEN tells you how long a piece of text is. Every character counts: letters, digits, spaces, punctuation and invisible characters such as line breaks or non-breaking spaces. It is the quickest way to check that IDs, phone numbers or postcodes have the right length, and to spot hidden spaces that make two seemingly identical cells different.
LEN is also a building block for other text formulas. =RIGHT(A2,LEN(A2)-4) removes the first four characters; comparing LEN(A2) with LEN(SUBSTITUTE(A2,",","")) counts how many commas a cell contains; and the same idea counts words.
With numbers LEN counts the stored value, not what the cell shows: a cell displaying $1,250.50 contains 1250.5, so LEN returns 6. Dates count the digits of their serial number (2026-03-15 is 46096, so 5).
Examples
1Length of a product name
| A | B | |
|---|---|---|
| 1 | Product | |
| 2 | Wireless Mouse | 14 |
Result: 14
Thirteen letters plus the space make 14 characters.
2Validate SKU length
| A | B | |
|---|---|---|
| 1 | SKU | Check |
| 2 | NYC-1042 | OK |
| 3 | NYC-104 |
Result: OK
Valid SKUs are always 8 characters. A2 passes; filled down, B3 would show Check because one digit is missing.
3Count extra spaces
| A | B | |
|---|---|---|
| 1 | Name (imported) | |
| 2 | Ana Silva | 3 |
Result: 3
The imported name is 12 characters long; after TRIM it is 9 (Ana Silva). Three unwanted spaces were present.
4Count the words in a cell
| A | B | |
|---|---|---|
| 1 | Report title | |
| 2 | Quarterly sales report for North region | 6 |
Result: 6
Removing all spaces shortens the text by 5 - one per gap between words - so the title has 5 + 1 = 6 words.
Tips
=LEN(A2)=0is a reliable test for an empty-looking cell, including cells that contain an empty string""from a formula.- To count a specific character:
=LEN(A2)-LEN(SUBSTITUTE(A2,"-",""))returns the number of hyphens. - If LEN shows more characters than you can see, look for non-breaking spaces (code 160) or line breaks with CODE and remove them with SUBSTITUTE or CLEAN.
Questions
Does LEN count spaces?
Yes. Leading, trailing and inner spaces are all characters. Use LEN(TRIM(A2)) if you want to ignore extra spaces.
How do I count characters in a whole range?
Use =SUMPRODUCT(LEN(A2:A100)), or simply =SUM(LEN(A2:A100)) in Microsoft 365.
Why does LEN return 5 for a date?
Dates are stored as serial numbers such as 46096. LEN counts those digits. Use LEN(TEXT(A2,"dd-mmm-yyyy")) to count the displayed characters.
Google Sheets
LEN also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
LEN in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | DÉLKA |
| Danish | LÆNGDE |
| Dutch | LENGTE |
| Finnish | PITUUS |
| French | NBCAR |
| German | LÄNGE |
| Hungarian | HOSSZ |
| Italian | LUNGHEZZA |
| Norwegian (Bokmål) | LENGDE |
| Polish | DŁ |
| Portuguese (Brazil) | NÚM.CARACT |
| Portuguese (Portugal) | NÚM.CARAT |
| Russian | ДЛСТР |
| Spanish | LARGO |
| Swedish | LÄNGD |
| Turkish | UZUNLUK |
Recipes that use LEN
- How to capitalize the first letter in Excel
- How to extract numbers from text in Excel
- How to remove line breaks in Excel
- How to remove spaces in Excel
- How to split first and last name in Excel