Text function

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)
ArgumentWhat it means
textRequiredThe 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

B2fx=LEN(A2)
AB
1Product
2Wireless Mouse14

Result: 14

Thirteen letters plus the space make 14 characters.

2Validate SKU length

B2fx=IF(LEN(A2)=8,"OK","Check")
AB
1SKUCheck
2NYC-1042OK
3NYC-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

B2fx=LEN(A2)-LEN(TRIM(A2))
AB
1Name (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

B2fx=LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))+1
AB
1Report title
2Quarterly sales report for North region6

Result: 6

Removing all spaces shortens the text by 5 - one per gap between words - so the title has 5 + 1 = 6 words.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 17 KB

Tips

  • =LEN(A2)=0 is 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.

LanguageFunction name
CzechDÉLKA
DanishLÆNGDE
DutchLENGTE
FinnishPITUUS
FrenchNBCAR
GermanLÄNGE
HungarianHOSSZ
ItalianLUNGHEZZA
Norwegian (Bokmål)LENGDE
PolishDŁ
Portuguese (Brazil)NÚM.CARACT
Portuguese (Portugal)NÚM.CARAT
RussianДЛСТР
SpanishLARGO
SwedishLÄNGD
TurkishUZUNLUK

Recipes that use LEN