Token Counter & Cost Estimator
Estimate LLM token usage and API cost locally — pick a model to see token count, input/output cost and context-window usage; nothing is uploaded.
>_ USAGE GUIDE
Paste a prompt, some code or a document, pick a model, and the tool gives you an estimate of the token count — locally in your browser — plus the input/output cost for that call and how much of the context window it uses. Nothing you type is ever uploaded.
Keep estimate and exact count apart: the real token count depends on each model's own tokenizer (vocabulary), which differs per vendor and per version and is often not public. This tool therefore offers two modes. The default uses character classification plus coefficients to produce an estimate with a stated error range: English prose runs about 4 characters per token (±10%), while Chinese carries more tokens per character, roughly 1–2 tokens each (±20%), always tagged ≈ estimate. Clicking Exact switches to true token-by-token counting with the o200k_base tokenizer — the vocabulary is lazy-loaded in its own chunk on first click and cached afterwards; models whose tokenizer is not public (Claude, Gemini, most Chinese providers) are labeled "aligned to o200k_base" for cross-model reference.
- Pick a model: choose from the presets; the currency symbol follows the vendor (Chinese providers are shown in ¥)
- Paste your text: characters, words, tokens and CJK character count update as you type
- Toggle exact mode: the Exact button counts tokens with
o200k_base; results are clearly labeled so the two modes never blur - Read the cost split: input cost plus output cost equals the total; note that prices are per 1,000,000 tokens
- Enter output tokens: use the current token count or your own expected value to get the output cost
- Watch window usage: the bar turns amber at 70% and red at 90%, and flags "over the window" past 100%
>_ FAQ
Q1 · Why does the estimate show an approximate value instead of an exact count?
Because exact tokenization depends on the model's own vocabulary, which varies across vendors and versions and is mostly not public. The default mode estimates from character counts and coefficients: these coefficients were regressed against o200k_base on a fixed corpus, with about 8% overall error — but casual, terminology-heavy or code-heavy text usually tokenizes higher than the estimate. When you need the precise figure, switch to the Exact mode, which counts with the public o200k_base vocabulary loaded on demand.
Q2 · Why does the same passage use more tokens in Chinese than in English?
In most vocabularies a common English word often fits into a single token (English averages roughly 5 characters per token), whereas a Chinese character usually costs 0.7 to 1.8 tokens depending on the tokenizer (o200k_base on the low end, cl100k_base-class higher). In other words, per character, Chinese carries far more tokens than English. For budgeting, estimating Chinese at about 0.8–1.5 tokens per character is a safe rule of thumb, with extra headroom for terminology- or code-heavy text.
Q3 · How is context-window usage computed, and what happens if it overflows?
Usage is (input tokens + output tokens) ÷ the model's context window. In a single request, the system prompt, prior turns, retrieved documents and the current input all occupy the window together, so counting the whole round is closer to reality. Past the limit, the model typically truncates the earliest content or errors out — which is exactly why checking the ratio up front helps.
Q4 · How is the cost computed, and do you convert currencies?
Input and output are each charged at the official price per 1,000,000 tokens multiplied by the amount used, as shown in the panel. No currency conversion is performed: Chinese providers (DeepSeek, Kimi, GLM) are shown in ¥ and the rest in $. The symbol follows the selected model, and the footer links to each vendor's official pricing page.
Q5 · Is my pasted content safe, and is it uploaded or logged?
No. The whole estimate runs inside your browser with no network request; your input is neither uploaded nor stored, and closing the page leaves nothing behind. That is precisely why you can paste sensitive prompts, key fragments or internal documents to compare the cost across models.