AI Token Counter & LLM Cost Calculator

Count the exact tokens in any text with the real BPE tokenizer for your model and estimate LLM API cost per request and per day — entirely in your browser, nothing is sent to an API.

Loading calculator…

What this tool does

Count the exact tokens in any text with the real BPE tokenizer for your model and estimate LLM API cost per request and per day — entirely in your browser, nothing is sent to an API. Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.

How to use the AI Token Counter & LLM Cost Calculator

  1. Enter or select text.
  2. Enter or select model.
  3. Enter or select expected output tokens per request.
  4. Enter or select requests per day.
  5. Read the calculated result; change any measurement to compare alternatives.

Formula

Tokenization: byte-pair encoding (BPE) splits text into the longest known subword chunks from the model's vocabulary (o200k_base for current OpenAI models). Cost per request = input tokens × input rate + output tokens × output rate, with rates per 1M tokens; daily cost = per-request cost × requests per day. Cached input tokens, when a provider offers them, are billed at the lower cached rate.
text
Text
model
Model
outputTokens
Expected output tokens per request
requests
Requests per day

Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.

Worked example

For ai token counter & llm cost calculator, the following measurements illustrate the exact method: Text: Large language models read and write text in tokens, not words. A token is a chunk of characters — often a word piece — produced by a byte-pair encoding tokenizer, and API pricing is charged per token, so counting tokens is how you predict cost.; Model: gpt-6-astra; Expected output tokens per request: 500; Requests per day: 1.

Inputs

  • TextLarge language models read and write text in tokens, not words. A token is a chunk of characters — often a word piece — produced by a byte-pair encoding tokenizer, and API pricing is charged per token, so counting tokens is how you predict cost.
  • ModelGPT-6 Astra (OpenAI)
  • Expected output tokens per request500
  • Requests per day1

Result

  • Exact token countUse the live token counter below — it runs the real BPE tokenizer for your chosen model in your browser.
  • Characters (Unicode code points)245
  • Words45
  • Lines1

Results explained

Exact token count
Exact token count from the formula above. Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.
Characters (Unicode code points)
Characters (Unicode code points) from the formula above. Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.
Words
Words from the formula above. Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.
Lines
Lines from the formula above. Exact token counts are computed in the live panel below with the real BPE encoding for OpenAI models. Non-OpenAI models (Claude, Gemini) use their own tokenizers, which are not public BPE files, so their counts are approximated with o200k_base and will differ slightly — Anthropic's counts typically run higher. Prices are the providers' standard per-1M-token rates as of 2026-10-08 and are estimates only; batch, flex and priority tiers differ. The exact counts above cover characters, words and lines only — the token count itself lives in the live panel because it needs the full tokenizer.

Frequently asked questions

A token is the unit of text a language model actually reads and writes. Text is split by a tokenizer into chunks — whole common words, word pieces, punctuation or even single characters. A rough English average is one token per ~4 characters, so a 1,000-word document is typically ~1,300 tokens. API billing, context limits and rate limits are all measured in tokens, not words or characters.

Each model family trains its own tokenizer vocabulary. OpenAI's current models use the o200k_base byte-pair encoding; older GPT-4 models used cl100k_base, which splits the same text into more tokens. Anthropic and Google use their own tokenizers, so the identical prompt can cost noticeably different token counts — and therefore different amounts — on different providers.

Only for ordinary English prose. It breaks badly on code (indentation, brackets and rare identifiers tokenize inefficiently), on JSON (every quote, brace and key adds tokens), on URLs and random strings (often close to one token per character), and on non-English text — many languages need far more tokens per word because their scripts are rarer in the tokenizer's training data. That is why this counter runs the real tokenizer instead of the rule of thumb.

When consecutive requests share a long identical prefix (a system prompt, a document, conversation history), providers can reuse the processed prefix and bill those tokens at a much lower cached-input rate — often 10% of the normal input price on OpenAI and Anthropic. If your workload repeats a big prompt, caching is usually the single largest cost saving available.

Two reasons multiply together: each provider's tokenizer produces a different token count for the same text, and each model has its own per-token rates, with output tokens typically priced 4–8× higher than input tokens. A model with cheap tokens but an inefficient tokenizer can cost more per task than a pricier model that tokenizes compactly — compare cost per task, not just cost per token.

No. The tokenizer (OpenAI's BPE rank tables, via the gpt-tokenizer package) is downloaded once as static data and runs entirely in your browser, and the price table is a dated static file. You can paste proprietary prompts or code and verify in your network tab that no request carries your text anywhere.

It depends entirely on the model and direction: as of October 2026, 1M input tokens range from about $0.10 on the smallest models (GPT-6 Luna, Gemini 2.5 Flash-Lite) to $10 on flagships (GPT-6 Astra, Claude Fable 5.1), and 1M output tokens from $0.40 to $50. Pick a model in the live counter below to see its exact rates.