LLM Token Counter

Estimate token counts for common LLM tokenizers.

The LLM Token Counter counts how many tokens your text uses under four OpenAI tokenizer encodings, and shows characters, words and characters per token. You can also enter your own price per million tokens to estimate a cost.

What are tokens?

Language models do not read characters or words directly. Text is first split into tokens, which are chunks such as whole common words, word pieces, punctuation or single bytes. Most OpenAI models use byte-pair encoding (BPE), where the vocabulary is learned from data. Context windows, rate limits and prices are measured in tokens, so a token count tells you whether a prompt fits and roughly what it will cost. English text averages around four characters per token, but code, numbers and non-Latin scripts usually take more tokens per character. Each model family has its own tokenizer. This tool uses the gpt-tokenizer library with OpenAI encodings: o200k_base, cl100k_base, p50k_base and r50k_base. Counts are only exact for models that use the encoding you picked, and they are estimates for other vendors.

How to use LLM Token Counter

  1. Choose an encoding Pick one in the Encoding selector. A note under it says which models it relates to.
  2. Paste your text Put the prompt or document in the Text box. The tokenizer loads on first use.
  3. Add a price (optional) Enter your price per 1M tokens in the price field, for example 2.50.
  4. Read the cards Tokens, Characters, Words and Chars per token appear, plus Estimated cost when a price is set.

Frequently asked questions

Is the count exact for Claude or Gemini?

No. The numbers come from OpenAI tokenizers. Other vendors use different tokenizers, so for those models the count is an estimate and may differ noticeably.

Which encoding should I choose for GPT-4o?

o200k_base. For GPT-4 and GPT-3.5 Turbo choose cl100k_base.

Why do tokens not equal words?

Tokens are sub-word chunks. Short common words are often one token, long or rare words split into several, and punctuation and whitespace also count.

Does the tool know current model prices?

No. You enter the price yourself, so it never shows out-of-date rates.

Is my text sent to a server?

No. Tokenization runs in the page and the text is not sent anywhere.

Why can Characters differ from the string length in code?

Characters are counted as Unicode code points, so an emoji counts as one character even though JavaScript string length counts it as two.