Token Inspector: Count Tokens and Cost Across Models
Tokens in GPT-6.1 Sol
Counting…
Counting tokens…
Defaults to the system message in Chat mode, otherwise 0. The cached part must be a stable prefix of the prompt.
Cost and context
GPT-6.1 Sol
Close proxyA published tokenizer that very likely matches this model, but the vendor has not confirmed it.
- Input tokens
- …
- Cost
- Counting…
Claude Haiku 5.5
EstimateThe vendor does not publish this tokenizer, so this is a labelled approximation.
- Input tokens
- …
- Cost
- Counting…
Llama 3.1 70B Instruct
ExactThe model's published tokenizer is used, so the count matches what the API bills.
- Input tokens
- …
- Cost
- Counting…
| Model | Tokenizer | Exactness | Tokens | vs fewest | Total cost (est.) | vs cheapest | Context |
|---|---|---|---|---|---|---|---|
| GPT-6.1 Sol | OpenAI o200k_base | Close proxy | … | – | price unavailable | – | – |
| Claude Haiku 5.5 | Claude (estimate) | Estimate | … | – | price unavailable | – | – |
| Llama 3.1 70B Instruct | Llama 3.x | Exact | … | – | price unavailable | – | – |
What a token is
Language models do not read characters or words. They read tokens: chunks of text drawn from a fixed vocabulary that the tokenizer learned before training. A token can be a whole word, part of a word, a space plus a word, a digit group, a punctuation mark or a single byte. Models are billed, limited and measured in tokens, so the token count is the number that matters for cost and context.
| Text | Tokens | Count |
|---|---|---|
| Hello world | [Hello] [ world] | 2 |
| tokenization | [token] [ization] | 2 |
| 1234567890 | [123] [456] [789] [0] | 4 |
| こんにちは | [こんにちは] | 1 |
A rough rule for English prose is about four characters per token, but code, numbers and other languages vary widely, which is why measuring beats guessing.
Why counts differ between models
Each model family trains its own tokenizer, so the same text splits differently. A larger vocabulary usually means fewer tokens for the same text. For example, the Japanese greeting こんにちは世界 is 2 tokens in o200k_base and 4 in cl100k_base, the older encoding used by GPT-4 and GPT-3.5 Turbo.
- Languages: text in languages that were less represented in the tokenizer's training data often needs more tokens per word.
- Code: indentation, brackets and identifiers split in vocabulary-specific ways.
- Numbers: some tokenizers group digits in threes, others split every digit, which changes the count of long numbers and IDs.
- Whitespace and structure: JSON, tables and long separator lines can cost more than they appear to.
Chat formatting overhead
Chat models do not receive your messages as plain text. The provider wraps each message in special tokens that mark the role and the end of the turn, and may add a few more tokens to prime the reply. Open models publish their exact chat template, so the Token Inspector can render it and count it. For OpenAI models the exact template is not fully public, so chat mode uses the ChatML layout as an approximation. The overhead is small per message but adds up in long conversations, and tool definitions add more on top.
Why Claude is an estimate
Anthropic does not publish the tokenizer that Claude models use, so no tool can reproduce it offline. The Token Inspector shows an estimate based on a comparable public tokenizer, labels it as an estimate and does not draw token boundaries. Anthropic also notes that newer models can use a different tokenizer, so counts can shift between model generations. For an exact figure, use Anthropic's token counting API, which counts a request without generating a reply.
Exact, close proxy and estimate
- Exact: the model's published tokenizer is used, with its chat template where one exists. The count should match the provider's.
- Close proxy: a published tokenizer that very likely matches, such as a newer OpenAI model counted with o200k_base. Expect a match, but the vendor has not confirmed it.
- Estimate: the vendor does not publish its tokenizer, so the number is an approximation. Treat it as a planning figure, not a billing figure.
Cost and context basics
API prices are quoted per million tokens, with separate rates for input and output, and output is usually the more expensive of the two. A request costs its input tokens times the input rate plus its output tokens times the output rate. The context window is the maximum of input plus output a model can handle in one request, so reserve room for the reply when you check that a prompt fits.
Many providers offer prompt caching: a repeated prompt prefix is billed at a lower rate for cached input tokens. The cost panel shows the difference when you enter a cached token count and the model has a cached price. Prices come from our model catalog and are estimates; check the provider's page before you budget. See the LLM cost calculator for monthly projections and model pricing for the catalog.
Privacy
Counting runs in your browser. Your text is not uploaded to our servers. Tokenizers for open models are downloaded from Hugging Face the first time you use them and then cached in your browser. The OpenAI encodings are bundled with the page. Share links store your inputs in the URL hash, the part after #, which browsers do not send to a server. Anyone who has the link can read the text, so do not share a link that contains secrets or personal data.
Learn more
- LLM cost calculatorProject monthly spend from token counts and traffic.
- Challenge: cost blow-up after launchDiagnose a bill that grew faster than usage.
- How to reduce LLM costsPractical ways to cut tokens and spend.
- BlogGuides for AI engineers.
- Agent StackBuild and measure agents with real tooling.
- AI engineering pathFrom software developer to production AI engineer.
Frequently asked questions
What is a token in an AI model?
A token is a chunk of text from the model's fixed vocabulary: a word, part of a word, a digit group, a punctuation mark or a byte. Models read, bill and limit text in tokens rather than characters. English prose averages roughly four characters per token, but code, numbers and other languages vary widely.
Why does the same text give different token counts in different models?
Each model family trains its own tokenizer with its own vocabulary, so the same text splits differently. Larger vocabularies usually give fewer tokens. Languages, code, numbers and whitespace all split differently. For example, one Japanese greeting is 2 tokens in OpenAI's o200k_base and 4 in cl100k_base.
Is the Claude token count exact?
No. Anthropic does not publish the tokenizer Claude uses, so the tool shows a labelled estimate based on a comparable public tokenizer and does not draw token boundaries. For an exact figure, use Anthropic's token counting API, which counts a request without generating a reply. Counts can also differ between Claude generations.
Does the Token Inspector upload my text?
No. Counting runs in your browser. Tokenizers for open models are downloaded from Hugging Face on first use and cached locally. Share links store your inputs in the URL hash, which browsers do not send to servers, but anyone with the link can read the text, so avoid sharing secrets or personal data.
How is the cost estimate calculated?
Cost is input tokens times the model's input price per million plus output tokens times its output price per million. If a model has a cached input price and you enter cached tokens, the tool also shows the cost with prompt caching. Prices come from our model catalog and are estimates, so check the provider's page.