LLM Token Calculator
Loading tokenizers…
| Encoding | Used by | Tokens | Cost |
|---|---|---|---|
| o200k_base | GPT-4o, GPT-4.1, o-series | … | — |
| cl100k_base | GPT-4, GPT-3.5-turbo, embeddings v3 | … | — |
| estimate (chars ÷ 3.7) | Claude, Gemini (no public tokenizer) | 0 | — |
How it works
Paste any text (a prompt, a document, a JSON payload) and see how many tokens it costs, computed with the same BPE tokenizers OpenAI uses in production: o200k_base (GPT-4o, GPT-4.1 and the o-series) and cl100k_base (GPT-4, GPT-3.5-turbo and the v3 embedding models). These are exact counts, not estimates: the tool runs a pure-JavaScript port of tiktoken in your browser.
A token is the unit LLM APIs bill by and the unit context windows are measured in. It is neither a character nor a word: common English words are often one token, rare words split into several, and whitespace and punctuation attach in non-obvious ways. As a rule of thumb English prose runs about 4 characters per token, code about 3, and non-Latin scripts far fewer characters per token. That is why eyeballing is unreliable, and why an exact count matters when you are close to a context limit or estimating a bill.
For Claude and Gemini there is no public tokenizer, so the tool shows a calibrated estimate (characters ÷ 3.7, the accepted English-prose average), clearly labelled as such. For budgeting it lands within about 10-15% on prose; the authoritative number comes only from each provider's API response.
To price a prompt, type your model's rate in the '$/1M tokens' field, taken from your provider's current pricing page, and each row shows the cost of this exact text. The tokenizer data files are a few megabytes, loaded once, only on this page, and cached by the PWA afterwards. Your text never leaves the browser. If you are trying to shrink a structured-data prompt, run it through the JSON ⇄ TOON Converter on this site and count again.
Frequently Asked Questions
Which models use o200k_base vs cl100k_base?
- o200k_base: GPT-4o, GPT-4o-mini, the GPT-4.1 family, and the o1/o3/o4 reasoning models. cl100k_base: GPT-4, GPT-4-turbo, GPT-3.5-turbo, and text-embedding-3. Newer OpenAI models generally use o200k_base; when in doubt, count with both, since the difference is usually small.
Why is the Claude and Gemini token count an estimate?
- Because Anthropic and Google do not publish their tokenizers. The chars ÷ 3.7 heuristic tracks English prose within roughly 10-15%, while code and non-English text deviate more. The exact count comes back in the usage field of every API response; use that for billing-critical numbers.
How many tokens fit in a context window?
- Whatever the model advertises, minus your output budget: a 128k-context model reading a 120k-token prompt has only about 8k tokens left to answer with. System prompts, tool definitions and conversation history all count against the same window.
Why does my short text count more tokens than expected?
- Because unusual words, camelCase identifiers, URLs, base64 and non-Latin scripts fragment into many small tokens, and emoji can be 3-7 tokens each. JSON is token-hungry for the same reason: every quote, brace and repeated key is tokenized. That is exactly what the TOON format (see the JSON ⇄ TOON Converter) is designed to fix.
Is my text uploaded to count the tokens?
- No. The tokenizers are pure JavaScript (the gpt-tokenizer port of OpenAI's tiktoken) running in your tab. The only network activity is downloading the tokenizer data files themselves the first time you open the page; your text generates zero requests.
Where do I find the price to enter?
- On your provider's pricing page: platform.openai.com/pricing, anthropic.com/pricing, ai.google.dev/pricing. Prices change often, so the tool deliberately doesn't hardcode them. Enter the current input-token rate for your model, and multiply output costs separately if you need both.
Characters per token: quick calibration by content type
Use these ratios for back-of-envelope sizing before you paste the real text.
| Content type | ≈ chars/token | 1,000 tokens ≈ |
|---|---|---|
| English prose | 4.0 | ~750 words |
| Italian / French / German prose | 3.5 | ~600 words |
| Source code | 3.0 | ~55 lines |
| Minified JSON | 2.8 | ~2.8 KB |
| Chinese / Japanese text | 1.5 | ~500 characters |
| Base64 / hex data | 2.5 | ~2.5 KB |
Measured with o200k_base on representative samples; individual texts vary. Count the real text above for exact numbers.