Token Counter: Estimate Prompt Tokens and API Cost
Paste a prompt to get an estimated token count and a cost at the per-token price you enter. It is a rule-of-thumb estimate, not a tokenizer result, which is enough to judge whether you will fit the context window and roughly what a run will cost.
When an estimate is enough
You rarely need an exact token count before you build; you need to know the order of magnitude.
The exact figure comes back from the API when you are actually billed. The job of an upfront estimate is to stop you sending a prompt that cannot fit the window.
- Deciding whether a long document fits a context window together with the output.
- Budgeting a batch job before you run it.
- Comparing the cost of two models on the same prompt.
- Choosing a chunk size for retrieval.
How to estimate without fooling yourself
The common rules of thumb are about four characters per token for English and about 1.5 characters per token for Chinese, with roughly ±15% error. Code, JSON, Japanese, and emoji deviate more because punctuation and multi-byte characters tokenize differently.
Characters are not bytes: one Chinese character is three bytes in UTF-8, so file size is a poor proxy. Price input and output separately, since output usually costs more, and remember that the context limit covers input plus output.
- Leave headroom for the response; a prompt that exactly fills the window cannot produce anything.
- Multi-turn chats carry the whole history, so the tenth message costs more than the first.
- Cached or batch input is often cheaper; enter the price you are actually billed.
- Prices change with model and version; the cost shown is your price times the estimate, not a quote.
Limits
Every model family has its own tokenizer, so the same text produces different counts on GPT and Claude. For an exact number, use the provider's tokenizer or the usage figure returned by the API.
Images, audio, and tool calls are billed on different rules and are not covered here.
- Long-context pricing can be tiered, with a different rate above a threshold.
- Whether retries, failed requests, and interrupted streams are billed depends on the provider's terms.
FAQ
How accurate is the token estimate?
Within roughly ±15% for ordinary prose, which is fine for budgeting and context checks. It can be further off for code, tables, Japanese, or emoji; use the provider's tokenizer when the exact number matters.
How different are Chinese and English token counts?
Chinese usually needs more tokens per character than English, which is why the rules of thumb differ, about 1.5 characters per token versus about 4. The same meaning often costs more tokens in Chinese.
Why is my actual bill higher than the estimate?
The estimate covers the prompt, not the response, and output is usually priced higher. Multi-turn history, retries, and system prompts also add tokens that are easy to forget.
Related tool:Token Counter