Tools / Token Counter
Token counter
GitHubPaste any text to count its tokens. Each token is highlighted in the input so you can see exactly where the tokenizer splits your text. Counts are exact for GPT and open models (Llama, Gemma, Qwen, Mistral); Claude and Gemini are shown as clearly-labeled estimates because they have no public offline tokenizer.
What is a token?
Language models do not read characters or words; they read tokens. A tokenizer splits text into subword pieces from a fixed vocabulary, so a common word like "the" is usually one token while a rare or long word is split into several. As a rough rule of thumb English runs about four characters per token, but the real count depends entirely on the model's tokenizer, which is why this tool counts with the actual tokenizer rather than guessing. Tokens are what you are billed for and what fills the context window, so counting them is the practical way to size prompts and estimate cost.
How to count tokens
There are three ways to count tokens, in decreasing order of accuracy. The exact way is to run your text through the model's real tokenizer, which is what this tool does in your browser: paste text, pick a model, and the count matches what the API charges. The second way is to read the usage fields the API returns after a request, which is exact but only tells you after you have paid for the call. The third is estimating from length with the rule of thumb of about four characters or three quarters of a word per token in English, useful for napkin math but off by a wide margin on code and non-English text. If you want to understand what the tokenizer is actually doing, read our guide on how tokenization works.
How the counting works
Every count runs entirely in your browser. For GPT models the tool uses tiktoken, OpenAI's own byte-pair-encoding tokenizer, which they open-sourced, so the count is exact and matches what the API charges. GPT-4o, GPT-4.1, and the o-series use the o200k_base vocabulary; GPT-4 and GPT-3.5 use cl100k_base. For open models the tool loads the model's real tokenizer.json from Hugging Face and runs it locally, so Llama 3, Gemma, Qwen3, and Mistral are exact too. The tokenizer data for a model is fetched once the first time you select it, then cached, which is the brief loading state you may see.
Why Claude and Gemini are estimates
Anthropic and Google have never publicly released the tokenizers for Claude 3/4 or Gemini, so there is no way to reproduce their exact counts offline. The only exact source is each provider's own token-counting API, which needs a server and an API key and cannot run on a static page. For those two the tool shows a clearly-labeled estimate produced by a reference tokenizer as a proxy, usually within roughly 10 to 20% of the true count, which is fine for planning but not for billing.
Characters, words, and tokens
Alongside tokens the tool shows character and word counts, which update instantly as you type. Comparing the three is a quick way to see how dense your text is: code, non-English scripts, and unusual formatting tend to use more tokens per character than plain prose, and switching models shows how differently each tokenizer handles the same text.
Privacy
Your text never leaves your browser; there is no server round-trip for counting. Only the tokenizer's vocabulary files are fetched from a public CDN, and only for open models the first time they are selected; your actual text is never uploaded.
Learn more
New to this? Read what a token is and how tokenization works.