How to Use the LEN Function in Google Sheets
=LEN(text). It counts every character, including spaces and nonprinting characters.
What LEN does
LEN counts characters. People use it to check a length limit (a product title, a tweet, an ID), to find cells with hidden extra spaces, and as a building block inside LEFT, RIGHT and MID formulas.
LEN syntax
=LEN(text)
Google's help page says LEN counts all characters, even spaces and nonprinting characters. If LEN returns a value you did not expect, check whether the text contains extra spaces or nonprinting characters.
A step-by-step example
Cell A2 holds the text Hello world.
| A | |
|---|---|
| 1 | Text |
| 2 | Hello world |
=LEN(A2)
This returns 11: ten letters and one space. You can also pass text directly in quotation marks, as the help page does with LEN("lorem ipsum").
Find hidden spaces
If a cell shows 5 letters but LEN says 7, two spaces are hiding in it. A lookup that "should" match can fail for exactly this reason. TRIM removes the extra spaces. Compare LEN(A2) with LEN(TRIM(A2)) to find the affected cells.
Common mistakes
- Forgetting that spaces count. A space is a character.
- Forgetting the quotation marks around direct text.
- Counting words. LEN counts characters, not words.
Try it yourself
Use the cell above (A2). Type your formula into the box, starting with =, then press Check.
Exercise 1: Count the cell
Write a formula that returns the number of characters in the text in A2.
Exercise 2: Count typed text
Write a formula that counts the characters in the text Google Sheets typed directly into the formula.
What to learn next
- TRIM: remove extra spaces from text.
- LEFT, RIGHT and MID: pull part of a text string by position.
- FIND: locate text inside a string.
Syntax and rules in this guide were checked against Google's LEN help page. See all guides.