Text and cleaning · About 4 minutes
Count characters with LEN
LEN counts the characters in a cell: letters, digits, spaces and symbols. =LEN( reads as "how many characters are in B2?"
It is a quick way to check typed data. An Indian mobile number has 10 digits, so a LEN of 9 or 11 means a digit was missed or typed twice.
You can compare the count with a number. =LEN( gives TRUE when B2 has exactly 10 characters, and FALSE when it does not.
Part of Plus
Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.
What LEN does
LEN counts the characters in a cell. Letters, digits, spaces and symbols all count, including spaces you can't see at the start or the end.
It is a quick check on typed data. Codes, ID numbers and ZIP codes usually have a fixed length, so a count that is one too high or too low points straight at the row that needs a second look. It also helps when a form or a system limits how long a text can be.
How to write LEN
=LEN(
- text
- The cell whose characters you want to count, like A2. You can also put text in quotes, like
"hello", which gives 5.
LEN worked example
A name badge has room for 8 letters, and spaces don't use any. In B2, count the characters in A2 without its spaces, then fill down to B5.
| A | B | |
|---|---|---|
| 1 | Name | Letters |
| 2 | Ana Silva | 8 |
| 3 | Tom Hale | 7 |
| 4 | Lee Ann Wu | 8 |
| 5 | Jo Mckay | 7 |
=LEN( SUBSTITUTE( A2, " ", ""))Swap every space in A2 for nothing, then count what is left: the first row shows 8. Filled down, the column shows 8, 7, 8 and 7, so every name fits.Common LEN mistakes
The count is higher than the text looks
The cell most likely has a hidden space at the start or the end. Count the cleaned text instead, with TRIM inside LEN, so only the real characters are counted.
A number with formatting gives a smaller count
LEN counts the stored value, not the way it is shown. A price formatted as 7.50 is stored as 7.5, so LEN gives 3. To count what you see, turn it into text with a format first, like LEN(.
Spaces between words are counted
LEN counts every space, so a two-word name counts one more than its letters. When only the letters matter, remove the spaces first with SUBSTITUTE, as in the example above.
LEN, COUNTA or COUNTIF?
LEN looks inside one cell and counts its characters. COUNTA looks across a range and counts how many cells are not empty. COUNTIF counts the cells in a range that match a test.
So use LEN to check the length of a code or a name, and the COUNT functions to count rows. LEN works the same way in Excel and Google Sheets. To count one character, like the dashes in a code, subtract the length without them, after SUBSTITUTE removes them, from the full length.
Questions people ask
Does LEN count spaces?
Yes. Every space counts, including ones at the start or end that you can't see.
How do I count characters without spaces?
Remove the spaces first: =LEN(.
How do I check if a phone number has 10 digits?
=LEN( shows TRUE for a 10-character entry. To show a word instead: =IF(.
Why does LEN give a different count than I expect for a number?
LEN counts the stored value, not the format. 5.50 shown with two decimals is stored as 5.5, so LEN gives 3.
Is there a character count in Google Sheets?
Yes, LEN works the same way there.