Home / Text guides / Guide: character frequency

Character Frequency: What It Is and How to Count It

Character frequency is how often each character appears in a text. It is simple to measure and surprisingly useful.

What is character frequency?

Character frequency is a count of each character in a piece of text, often shown as a percentage of the total. Letter frequency is the same idea limited to letters.

Why it matters

Frequency analysis breaks simple substitution ciphers, because each plaintext letter always maps to the same cipher letter and keeps its frequency. Compression methods such as Huffman coding give shorter codes to common characters. Linguists use frequency to compare languages, and developers use it to inspect data.

English letter order

In ordinary English text, the most common letters are roughly E, T, A, O, I, N, S, H and R. Exact figures vary with the sample, so treat any table as an average.

How to count it

By hand, write each character once and add a tally mark every time you see it. In code, a counter does the job:

from collections import Counter
text = "hello world"
print(Counter(text).most_common())

The result lists each character with its count, most common first.

Common uses in practice

  • Breaking classical ciphers and solving puzzles
  • Detecting the language of a text
  • Checking data for unexpected characters
  • Designing compression codes

Tips for accurate results

Use a large sample, decide in advance whether case and spaces matter, and clean the text if it contains markup. Remember that frequencies describe a sample, not a rule for every sentence.

Try it

Count your own text with the character frequency counter, compare against English with the letter frequency counter, or view an A to Z table with the by-letter page.

Count it instantly. Paste your text and see every character ranked by frequency.

Open the character frequency counter or try the letter frequency counter.

Frequently asked questions

What is the difference between character and letter frequency?

Character frequency counts everything, including digits, punctuation and spaces. Letter frequency counts letters only.

Is character frequency the same in every language?

No. Each language has its own pattern, which is why frequency analysis can identify a language.

Does character frequency work on short texts?

Only roughly. The pattern becomes reliable as the text gets longer.

How do I find the most common character in a text?

Count every character and sort by count. The counter on this site does that automatically.

Why do spaces often rank first?

In normal prose the space is the single most common character because it appears between every word.