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.
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.
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.
o200k_base. For GPT-4 and GPT-3.5 Turbo choose cl100k_base.
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.
No. You enter the price yourself, so it never shows out-of-date rates.
No. Tokenization runs in the page and the text is not sent anywhere.
Characters are counted as Unicode code points, so an emoji counts as one character even though JavaScript string length counts it as two.