Home / Guides / Letter count guide

How to Count Letters in a Text

Letters, characters and words are different counts. This guide explains the difference and shows how to count each one by hand, in a spreadsheet and in code.

Want the numbers right now? Paste your text in the letter counter or the character counter.

Letters, characters and words

CountWhat it includes
CharactersEverything: letters, digits, spaces, punctuation, symbols and line breaks
Characters without spacesEverything except whitespace
LettersOnly alphabetic characters
WordsGroups of letters and digits separated by spaces or punctuation

The sentence "Hello, World! 123" has 17 characters, 15 without spaces, 10 letters and 3 words. The three tools linked above give you each of these numbers: characters, characters without spaces and letters only.

Count by hand

For short text, write the letters in groups of five or ten and count the groups. For a single letter, scan the text and make a tally mark each time it appears. It works for a word or a line, and it becomes unreliable after that, so use a tool for anything longer.

In Word and Google Docs

Both programs have a word count window with characters and characters without spaces. Look for Word Count in the review or tools menu. They do not show a letters only number, so paste the text into the letters only counter for that.

In Excel and Google Sheets

With the text in A1:

Characters:                =LEN(A1)
Without spaces:            =LEN(SUBSTITUTE(A1," ",""))
Count the letter e:        =LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"e",""))
Words:                     =LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1

The letter formula turns the text to lowercase first, so E and e are both counted. To count a letter across a range, wrap the formula in SUMPRODUCT. The word formula returns 1 for empty cells, so wrap it in IF(A1="",0,...) if you have blanks.

In code

// JavaScript: letters in any alphabet
const letters = (text.match(/\p{L}/gu) || []).length;

# Python
letters = sum(ch.isalpha() for ch in text)

// PHP
$letters = preg_match_all('/\p{L}/u', $text);

To count a single letter, replace the pattern with that letter and add a case-insensitive flag. In the terminal, wc -m file.txt counts characters, and grep -o e file.txt | wc -l counts the letter e.

Pitfalls that change the number

  • Emoji and accents. Some programs count by code units, so an emoji can count as 2 characters and é written as e plus an accent as 2. Counting what the reader sees avoids this.
  • Line endings. Windows ends a line with two characters, other systems with one. A good counter treats both as one break.
  • Special spaces. Non-breaking spaces and tabs look like spaces but are different characters.
  • Curly quotes and dashes. They are punctuation, not letters, even when copied from a document.
  • Case. Decide if A and a are the same letter before you count a specific one.

See also

Frequently asked questions

What is the difference between letters and characters?

Characters include everything in the text, such as digits, spaces and punctuation. Letters are only the alphabetic characters.

How do I count a specific letter in Excel?

Use =LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"e","")), replacing e with your letter in lowercase.

Why do two tools give different counts for the same text?

They treat emoji, accents, tabs and line breaks differently. Check the rules of each tool.

How do I count letters in code?

In JavaScript, match the pattern \p{L} with the u flag and count the matches. In Python, count the characters where isalpha() is true.