Token Counter
Estimate token counts for GPT-4o, GPT-3.5 Turbo, Claude Sonnet 5, Gemini 3.1 Flash-Lite and Mistral Large. Paste text, see counts per model side-by-side. Files never leave your browser.
| Model | Tokens | Input $/1M | Cost (this text) |
|---|
Why token counts vary by model
Every interaction with an LLM is metered in tokens — sub-word units that the model's tokenizer carves from your text. Tokens drive both context-window limits ("does this fit?") and pricing ("how much will this cost?"). The exact count depends on the model's tokenizer, which you usually don't have at hand. This tool gives you a fast estimate for each of the five models listed side-by-side, plus the dollar cost for the input text against each model's published per-token price.
Budget, cost, and context-window planning
- Sizing a system prompt to make sure it (plus expected user input and headroom for output) fits the context window.
- Estimating the API cost of a batch job before you run it — paste 100 representative inputs and multiply.
- Comparing prompt-engineering iterations: did the new prompt actually get shorter, or did you just feel like it did?
- Sanity-checking that a "this is too long" error wasn't caused by hidden whitespace, BOM markers, or copy-paste noise.
Heuristic accuracy vs real tokenizers
- These are heuristics, not the real tokenizers. OpenAI (tiktoken), Anthropic, Google and Mistral each use their own tokenizer, and this page runs none of them: it divides the character count by a fixed ratio per model. Treat every number as a sizing estimate, not a billing figure; code, dense JSON and non-English text drift furthest. Anthropic says Claude 4.7 and later models use a newer tokenizer that produces about 30% more tokens for the same text, so the Claude Sonnet 5 row uses a lower characters-per-token ratio, but it is still an approximation.
- Why we don't ship the real tokenizers. tiktoken alone is ~1 MB of WASM + data files; loading it just to count tokens would bloat the page tenfold. If you need exact counts (e.g. you're close to a hard context limit), run
tiktokenlocally for OpenAI models, or use the provider's token-counting endpoint for Claude and Gemini models. - What we get right. Order-of-magnitude estimates ("is this 500 or 5,000 tokens?") and rough cost comparisons between models. Close calls between models, or a count near a limit, need the real tokenizer.
Pricing and the output multiplier
- Costs are input prices per 1M tokens as of 20 Oct 2026. Output tokens are typically more expensive — multiply by 3–5× for a worst-case output estimate.
- Prices change. Check the provider's pricing page before relying on these numbers for a real budget.
Tokens, words, whitespace, and CJK
- Tokens ≠ words. An English word averages 1.3 tokens; "antidisestablishmentarianism" is roughly 7. Code and structured text tokenise much higher per character.
- CJK text is dense. Each Chinese / Japanese / Korean character can be its own token, so 1000 chars ≈ 1000 tokens — much more expensive per "character" than English.
- Hidden characters add up. Pasted text with zero-width joiners, NBSPs, or BOMs gets counted too. If your token count looks suspiciously high, look for invisible characters first.
- System + user + assistant tokens compound. The "context window" budget includes every message in the conversation. Don't size your input against the raw limit; leave 30–50% headroom for replies.
Sizing a batch job
Paste a 500-word prompt and the tool estimates roughly 650–700 tokens — English runs about 1.3 tokens per word — then multiplies by each model's published input price so you can see the cost per model side by side. Multiply that by the 100 inputs in your batch job and you know the bill before you spend a cent.
Accuracy, output billing, and whitespace traps
How accurate is the count? It's a heuristic, not the model's real tokenizer, so treat it as sizing rather than billing truth — we haven't measured it against every provider's tokenizer, so allow a wide margin, especially for code, JSON and non-English text.
Why do models disagree on the count? Each model carves text with its own tokenizer, so the same string splits into a different number of sub-word units — and therefore a different price.
Does this include output tokens? No — it measures your input text only. Output is billed separately and usually at a higher rate, so leave headroom in your estimate.
Do spaces and line breaks count? Yes — whitespace becomes tokens too. That's why a stray BOM marker or copy-paste noise can quietly inflate a count and trip a context-window limit.
Chars, tokens, words — the rough conversions that matter for cost
LLMs bill by token, not word, and a token is roughly a common word-chunk of about four characters of English. That gives usable back-of-envelope conversions, but the ratio shifts hard by content type:
| Content | Rough chars/token | 100 tokens ≈ |
|---|---|---|
| Plain English prose | ~4 | ~75 words |
| Code / JSON | ~3 (denser) | Far fewer “words”; braces & punctuation each cost a token |
| Rare words, other languages, emoji | <2 | One emoji or CJK glyph can be several tokens |
Two traps: (1) whitespace and punctuation are tokens too, so minifying JSON genuinely cuts cost; (2) the same prompt tokenises differently across model families — treat any “words × 1.3” estimate as a ceiling to budget against, not an exact bill.
Context window budgeting in practice
A common mistake is sizing only the user prompt against the context limit. In reality, the window must hold the system prompt, all prior conversation turns, tool-call results, and the model's own output. Paste your system prompt here first to see its baseline cost, then add representative user messages to estimate the per-turn overhead. Reserve at least 30% of the window for the model's reply — a tight budget forces truncated or degraded output even when the input technically fits.
Comparing tokenisation across model families
The side-by-side layout is the point of this tool. A 500-word English paragraph might tokenise to 650 tokens on GPT-4 and 620 on Claude because their BPE vocabularies differ. For most planning purposes the gap is negligible, but for budget-sensitive batch workloads the difference compounds across thousands of calls. Scan the per-model row to find the cheapest option that meets your quality bar.
Estimating output cost separately
This tool measures input tokens only. Output tokens — the model’s reply — are billed at a higher per-token rate on every major provider. For a rough total-cost estimate, multiply the input cost shown here by three to five depending on expected reply length. If your application generates long structured outputs (reports, code, JSON payloads), the output share dominates the bill and deserves its own estimate.