LEN

Count the number of characters in a text string.

|
Excel All versions
|
Google Sheets Supported

Spreadsheet editor

Syntax

=LEN(text) Returns: Number

Arguments

Argument Required Description
text Yes The text string whose characters you want to count. Spaces count as characters.

About

LEN counts how many characters are in a text string and returns that count as a number. It counts everything inside the cell, including letters, digits, spaces, and punctuation, so a value like "Hello, Excel!" returns 13. Point it at a single cell or type the text directly, for example =LEN(A2).

Use LEN whenever the length of an entry matters. It is handy for validating input (flagging phone numbers or codes that are too short), spotting extra spaces in imported data, and building dynamic formulas. LEN pairs well with LEFT, RIGHT, and MID when you need to pull part of a string by position, and with FIND or SEARCH to measure where one piece of text sits inside another.

A common trick combines LEN with SUBSTITUTE to count how often a character appears, such as counting words by counting spaces. If your text contains double-byte characters and you need bytes instead of characters, use LENB instead.

Examples

Spaces and blank cells count

See how LEN counts every character, including the spaces you cannot see. Add a leading or trailing space to an entry and watch the length jump, then try a blank cell to confirm it returns 0.

Spreadsheet editor

Count words with LEN and SUBSTITUTE

Turn LEN into a word counter by comparing the length before and after removing spaces. Edit a sentence to add or drop words and watch the count update.

Spreadsheet editor

Watch out for

Forgetting that spaces count

LEN counts every space, including leading and trailing ones. A value that looks like 5 characters may return 6 or 7 because of spaces you cannot see.

Wrap the text in TRIM before measuring, for example =LEN(TRIM(A2)), so extra spaces do not throw off the count.

Measuring a number's value, not its display

LEN works on the underlying value, not the formatting. =LEN(A2) for a date or a currency amount counts the raw serial number or unrounded number, not what you see on screen.

Convert the number to text first with TEXT, such as =LEN(TEXT(A2,"mm/dd/yyyy")), so LEN counts the formatted result.

Counting bytes instead of characters

For most languages LEN is what you want, but with double-byte character sets it can give surprising results if you actually needed the byte count.

Use LENB when you need the number of bytes rather than the number of characters.

Tips & notes

LEN returns 0 for an empty cell, which makes it a quick way to check whether a cell is blank inside a larger formula. To count characters across several cells at once, combine LEN with SUMPRODUCT, for example =SUMPRODUCT(LEN(A2:A10)).

Common questions

Does LEN count spaces?

Yes. LEN counts every character, including spaces, punctuation, and digits. If you want to ignore extra spaces, run the text through TRIM first.

Can LEN count characters in a number?

Yes, but it counts the underlying value, not the formatting. Suppose A1 contains 1500 formatted as $1,500.00. In this case, =LEN(A1) would return 4. For a formatted result like a date or currency, wrap the cell in TEXT first.

How do I count how many times a character appears?

Compare the length before and after removing the character with SUBSTITUTE: =LEN(A2)-LEN(SUBSTITUTE(A2,"-","")) counts the dashes in A2.

Is LEN available in Google Sheets?

Yes. LEN works the same way in Google Sheets, using LEN(text) to count the characters in a string.