Estimate tokens and API cost for GPT, Claude, Gemini, Llama and open models. Check context window fit and compare prices across models instantly.
Paste your prompt and this tool estimates how many tokens it will consume, what an API call will cost, and how much of the model’s context window it fills. It covers the major commercial models — GPT-4o, GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, o1, Claude Opus 4, Claude Sonnet 4, Claude 3.5 Sonnet, Claude 3 Haiku, Gemini 2.0 Flash, Gemini 1.5 Pro, Amazon Titan — plus open models such as Llama, Qwen, Gemma, Mistral, and DeepSeek, with the ability to search Hugging Face for any other model by name.
One thing to be upfront about: this is an estimator, not a tokenizer. It does not run tiktoken or any model’s actual vocabulary. It applies a per-family heuristic and typically lands within 5–15% of the true count, with the error depending on your text’s language, code density, and punctuation. For exact counts — billing reconciliation, a hard context-limit check — run the official tokenizer for your model. For the thing people actually use a token counter for, which is deciding whether a prompt is affordable and whether a document will fit, an estimate in that range is enough to make the decision.
Language models do not read characters or words. They read tokens: sub-word fragments produced by a tokenizer that was trained to split text efficiently over the model’s training corpus. Common English words are usually one token each. Rare words split into pieces. Whitespace is typically attached to the following word, so “ the” and “the” can be different tokens.
The rule of thumb you will see everywhere — roughly 4 characters per token for English prose, or about 0.75 words per token — is a decent starting point, and it is where this tool starts too. But it is an average over one kind of text, and the moment your input stops being English prose the ratio moves:
There is no universal token. Each model family ships its own tokenizer with its own vocabulary, and vocabulary size is the dominant factor: a bigger vocabulary packs more characters into each token, so the same text produces fewer tokens.
That is exactly how this tool’s estimator is calibrated. Rather than one global ratio, it uses a characters-per-token figure per model family, derived from that family’s vocabulary size:
| Family | Approx. vocab | Chars per token used |
|---|---|---|
| Gemma | 256K | 4.2 |
| OpenAI (o200k) | 200K | 4.2 |
| Moonshot | 160K | 4.0 |
| Qwen | 152K | 3.8 |
| Mistral (Nemo and later) | 131K | 3.7 |
| DeepSeek | 129K | 3.8 |
| Llama | 128K | 3.8 |
On top of the base character division, the estimator adds small adjustments for word count, punctuation, and numeric runs, since punctuation and digits tend to become tokens of their own. That is why the number here is closer than a flat “divide by 4” but still not exact.
The practical consequence: never carry a token count from one model to another. The same prompt priced against GPT-4o and against Llama 3.1 gives different token totals, and comparing providers on price-per-million-tokens alone without accounting for tokenizer efficiency will mislead you.
Pricing figures are public list prices as of June 2026 and are labelled as such in the interface. Providers change prices frequently, sometimes with little notice, so confirm current rates with the provider before committing to a budget.
Suppose you are building a document-summarisation feature. Each call sends a 12,000-token document and receives a roughly 600-token summary — an output ratio of 0.05. If input costs $2.50 per million tokens and output $10.00 per million, one call is $0.030 of input plus $0.006 of output, about $0.036. At 50,000 documents a month, that is roughly $1,800.
Now flip it to a code-generation feature: a 1,000-token prompt producing 4,000 tokens of code, a ratio of 4. Input is $0.0025, output is $0.040 — the output dominates completely, at more than 90% of the cost. Estimating with input tokens alone would have understated the bill by a factor of sixteen. This is the single most common budgeting mistake with LLM APIs, and it is why the ratio control exists rather than being hidden behind an assumption.
The context window is the hard limit on input plus output for a single request. The models here range from 8,192 tokens (GPT-4, Amazon Titan) through 128,000 (GPT-4o, GPT-4 Turbo, Llama 3.x), 200,000 (o1 and the Claude models), up to 1–2 million for Gemini.
A large context window is a capability, not a free one. You pay for every token you put in it, on every call. Filling a 200,000-token window on each request when 8,000 tokens of retrieved context would answer the question is a twenty-five-fold cost increase for no benefit — and often a quality loss too, since models are measurably worse at using information buried in the middle of a very long context. Use the context bar here to see how much headroom you actually have, then aim to use less of it.
If the answer to your cost problem is running a model yourself, size the hardware first with the LLM VRAM calculator, check throughput with the inference speed calculator, and compare the total against API pricing with the self-hosted LLM cost calculator.
It is a heuristic estimate, typically within 5–15% of the true count. It does not run the model’s real tokenizer. Use it for budgeting and context-fit decisions; use the official tokenizer library (tiktoken for OpenAI, and each provider’s equivalent) when you need an exact number.
Roughly 1,300 tokens for ordinary English prose, using about 0.75 words per token. Code, numeric data, and non-English text will be higher — sometimes much higher.
Because each model family uses a different tokenizer with a different vocabulary. Larger vocabularies encode more characters per token. This tool accounts for that with a per-family characters-per-token figure rather than one global ratio.
They are public list prices verified as of June 2026 and labelled with that date in the tool. Provider pricing changes often — confirm with the provider before basing a budget on them.
Input tokens are processed in parallel in a single forward pass, while output tokens are generated one at a time, each requiring a full pass through the model. Generation is the expensive part, and pricing reflects it — typically two to five times the input rate.
It is your estimate of how long the response will be relative to the prompt, used to project output token cost. Set it low for summarisation and classification, high for generation and long-form writing.
Yes. Switch to the open models source for Llama, Qwen, Gemma, Mistral, DeepSeek, and others, or search Hugging Face for a model by name. Open models show token counts and context fit but no per-token price, since self-hosting is not billed per token.
Token estimation and cost calculation run entirely in your browser. The only network request the tool makes is to the Hugging Face model index if you actively search for a model by name — that sends your search term, not your prompt text.
Tokens are the fundamental units that large language models (LLMs) use to process text. Unlike words or characters, tokens are subword units determined by the model's tokenizer — a word might be a single token, or it might be split into multiple tokens depending on its frequency in the training data. Understanding token counts is essential for managing API costs, staying within context window limits, and optimizing prompt engineering.
Different LLM providers use different tokenizers, meaning the same text produces different token counts depending on the model. This tool counts tokens for popular models so you can estimate costs and ensure your prompts fit within context limits.
| Model Family | Tokenizer | Avg. Tokens per Word | Context Window |
|---|---|---|---|
| GPT-4 / GPT-4o | cl100k_base (tiktoken) | ~0.75 | 128K tokens |
| Claude 3.5 | Custom BPE | ~0.75 | 200K tokens |
| Gemini 1.5 | SentencePiece | ~0.8 | 1M-2M tokens |
| Llama 3 | Custom BPE | ~0.8 | 128K tokens |
| Mistral | SentencePiece | ~0.8 | 32K-128K tokens |
The text "Tokenization is important" might tokenize as:
| Text | GPT-4 Tokens | Count |
|---|---|---|
| "Hello world" | ["Hello", " world"] | 2 |
| "Tokenization" | ["Token", "ization"] | 2 |
| "🎉" | ["🎉"] | 1 |
| "antidisestablishmentarianism" | ["ant", "idis", "establish", "ment", "arian", "ism"] | 6 |
Common English words are typically single tokens. Rare words, technical terms, and non-English text split into more tokens.
Calculate how much VRAM any LLM needs to run locally. Pick a model, quantization, and context size — see download size, total memory required, and which GPUs it fits on.
Estimate LLM tokens per second from memory bandwidth, model size, quantization, and context window. Compare generation speed across GPUs and understand the memory-bandwidth bottleneck.
Is it cheaper to self-host an LLM or use an API? Compare GPT, Claude, and Gemini API costs against running open models on your own hardware or cloud GPUs — with break-even timelines.