Token Counter & Cost Estimator

Count LLM tokens and estimate prompt costs without leaving your browser: exact tiktoken counts for GPT models, clearly-labelled ≈ estimates for Claude and Gemini, and cost figures built on dated, officially-sourced prices.

Runs 100% in your browser — no upload, no API key.

How To Use

  1. Pick the model you are budgeting for. OpenAI models are counted exactly with their real tiktoken vocabulary; Claude, Gemini and other models are counted with a clearly-marked approximation.
  2. Paste your prompt into Single text, or switch to Chat messages to build the conversation the way the API receives it — the count updates as you type.
  3. Read the big number with its label: Exact for OpenAI models, ≈ Estimate for everything else, with the reason spelled out underneath.
  4. Check the cost card: input cost for your text, what the same length would cost as output, and the date the prices were verified.
  5. Watch the context bar to see how much of the model's window your input consumes before you send it.
  6. If your text contains control tokens like end-of-text markers, the count treats them as ordinary characters and tells you so — tick Count special tokens as single tokens for the vocabulary-true count.

Usage Example

Paste a 12,000-character system prompt, select GPT-4o, and the tool reports the exact token count (say, ≈3,100 tokens for typical English prose), the Exact · tiktoken o200k_base badge, and a cost line of about $0.0078 input at GPT-4o's $2.50 per million tokens (price checked October 2026). Switch the model to Claude Sonnet 5 and the badge flips to ≈ Estimate: same text, o200k approximation, with a note that Anthropic's newer tokenizers can emit roughly 30% more tokens than the approximation suggests.

For a chat budget, switch to Chat messages, add a system message and three user turns, and pick gpt-4o: the total includes 4 × 3 wrap tokens plus the 3-token reply primer, and the Message wrap overhead line shows exactly how many of the tokens are packaging rather than your content.

Use Cases

  • Prompt budgeting: see whether a system prompt plus a document fits in a model's context window before you paste it into an API call that bills per token.
  • Cost estimation: multiply your recurring prompt by the per-million input price to sanity-check a monthly API bill — or compare two models' prices for the same prompt before committing.
  • Chunking decisions: split long documents into pieces that stay under a target token count instead of guessing by characters.
  • Privacy-sensitive drafting: count tokens for prompts you cannot paste into any web service — nothing here is uploaded, logged, or stored, and there is no account to breach.
  • Teaching and docs: show a team what "a token" means by pasting their own text and seeing the exact/vs-approximate distinction explained inline.

Best Practices

  • Match the model to your provider. An exact GPT count says nothing about Claude's billing — for cross-provider budgeting, use the ≈ estimate as a middle anchor and re-check with the provider's own counter for anything expensive.
  • Count conversations as conversations. Per-message wrap overhead is small on long turns but dominates short chatty ones; use the Chat messages tab when your real workload is many short turns.
  • Treat output cost as a separate budget line. Generation is billed at the output rate, which is typically 3–10× the input rate; the output reference line exists so you don't price a generation workload at input rates.
  • Re-verify prices before big commitments. The date next to the cost card is the day every number on this page was checked against official pricing pages; providers change prices without notice.
  • Don't optimize below ~1k tokens. Tiny prompt savings cost more in engineering time than they save in API spend; the tool is most valuable on prompts you send thousands of times.

Frequently Asked Questions

Is my text uploaded to a server?

No. Counting and cost math run entirely in your browser — the tokenizer vocabulary is bundled with the page and loads as a local file, and no text is ever sent anywhere. This is the key difference from tools that need your API key: they forward your text to a provider endpoint just to count it, while this tool never lets your prompt draft leave the tab.

Is the GPT token count exact?

Yes, for OpenAI models. The tool uses the tiktoken vocabulary that matches each model: cl100k_base for GPT-3.5 and GPT-4, o200k_base for GPT-4o, GPT-4.1, the o-series and GPT-5 (GPT-5 still uses o200k_base). These are the same vocabularies the OpenAI API bills against, so the count you see is the count you pay for, up to the small rounding the provider itself does.

How accurate are the Claude and Gemini estimates?

They are approximations, and the tool labels every one with a ≈ prefix. Anthropic and Google have not published their tokenizers, so there is no way to count exactly in a browser. The count uses the o200k_base vocabulary as a stand-in and is usually in the right ballpark for English text, but Claude 4.7+ models emit roughly 30% more tokens than earlier Claude models per Anthropic's own figures, so treat estimates as budgeting help, not billing. Anthropic and Google both offer a free count_tokens API if you need the exact number and have an API key.

Do chat messages add extra tokens?

For OpenAI models, yes: each message is wrapped in the model's chat template (role markers and separators), and a reply primer is added at the end — typically 3–4 tokens per message. This tool counts with the real chat template, includes all of that in the total, and shows the wrap overhead as its own line. Anthropic and Google do not publish per-message constants, so for those models the estimate covers message contents only and the tool says so explicitly.

How is the cost estimate calculated?

Token count divided by one million, multiplied by the model's published input price; a second line shows what the same token count would cost if the model generated it as output. Tiered pricing (like Gemini's over-200k prompts) is applied automatically based on your count. The date the prices were checked is shown right next to the numbers — prices change often, so always confirm with the provider before relying on them.

What is the context window bar?

It shows how much of the selected model's context window your input would consume. The limits come from each provider's documentation (for example 128,000 tokens for GPT-4o and 400,000 for GPT-5, as of October 2026) and are verified when the price list is updated. Models whose limits we could not verify do not show the bar rather than showing a made-up number.

Why is my count different from OpenAI's tokenizer page?

Two usual reasons: your text contains special tokens such as the end-of-text marker (written `.endoftext.` in this page, angle-bracket delimiters in raw form) — this tool counts those as ordinary characters and tells you it did, and the official page may refuse them outright; or you are comparing plain-text mode with chat mode, where each message adds its template wrap. For plain text with no special tokens, the count here matches what the API bills for the same input.

What are special tokens?

They are reserved control strings like the end-of-text marker (written `.endoftext.` in this page) that mark document boundaries for the model. They are tokens in the vocabulary but not ordinary text, and the OpenAI API rejects them in raw input. This tool counts them as ordinary characters by default and tells you when it did; if your workflow deliberately includes them, the "Count special tokens" option counts each as the single token it really is.

Does it work offline?

After the first load, yes. The page, the counting code and the tokenizer vocabulary are static files served with long-lived caching, so reloads and repeat counts work without a network connection. There is no account, no telemetry and no server-side component at all.

Which models show only approximate counts, and why?

Every non-OpenAI model: Claude, Gemini, and open-weight families like DeepSeek, Llama and Qwen. Their tokenizer vocabularies are either unpublished (Claude, Gemini) or public but huge — 7 to 11 MB per model for DeepSeek, Llama and Qwen — which would make the page slow for everyone to benefit a few users. For those, the tool counts with the o200k approximation, labels it with ≈, and explains why right next to the number.