LLM Token Counter

Paste any prompt or document to count tokens for GPT, Claude, and Gemini, check whether it fits each model's context window, and see what it costs.

GPT tokens (exact)
…
o200k_base: GPT-4o, GPT-5, GPT-6
Claude tokens (est.)
…
Opus 4.7+, Sonnet 5, Fable
Characters
279
Words
45

Loading tokenizer (about 2 MB, one time)…

20 rows
Token count, context window usage and cost per model
Claude Fable 5.1
Anthropic
…1M
0.00%
$0$0
Claude Opus 5.5
Anthropic
…1M
0.00%
$0$0
Claude Opus 5
Anthropic
…1M
0.00%
$0$0
Claude Sonnet 5
Anthropic
…1M
0.00%
$0$0
Claude Sonnet 4.6
Anthropic
…1M
0.00%
$0$0
Claude Haiku 4.5
Anthropic
…200K
0.00%
$0$0
GPT-6 Astra
OpenAI
…1.05M
0.00%
$0$0
GPT-6 Sol
OpenAI
…1.05M
0.00%
$0$0
GPT-6 Luna
OpenAI
…1.05M
0.00%
$0$0
GPT-5.5
OpenAI
…1.05M
0.00%
$0$0
GPT-5.4
OpenAI
…1.05M
0.00%
$0$0
GPT-5.4 mini
OpenAI
…400K
0.00%
$0$0
GPT-5 mini
OpenAI
…400K
0.00%
$0$0
GPT-4.1
OpenAI
…1.05M
0.00%
$0$0
Gemini 3.8 Flash
Google
…1.05M
0.00%
$0$0
Gemini 3.5 Flash
Google
…1.05M
0.00%
$0$0
Gemini 3.5 Flash-Lite
Google
…1.05M
0.00%
$0$0
Gemini 3.1 Pro (preview)
Google
…1.05M
0.00%
$0$0
Gemini 2.5 Pro
Google
…1.05M
0.00%
$0$0
Gemini 2.5 Flash
Google
…1.05M
0.00%
$0$0

OpenAI counts are exact (o200k_base). Claude and Gemini counts are ranges, since those tokenizers aren’t published for the browser; use Anthropic’s count_tokens API or Gemini’s countTokens for exact numbers. Costs use the midpoint and standard list prices, last checked 2026-09-25. Your text never leaves your browser.

What is a token?

Language models don't read characters or words. They read tokens, which are chunks of text from a fixed vocabulary. Common words are usually one token (“the”, “agent”), while rare words, code identifiers, and non-English text split into several. Everything about using an LLM API is measured in tokens: price, context-window limits, rate limits, and latency.

How this token counter works

  • OpenAI (GPT-4o, GPT-5.x, GPT-6): exact counts from the o200k_base encoding, the same byte-pair encoding OpenAI's tiktoken library uses.
  • Anthropic Claude: an estimated range. The older tokenizer (Sonnet 4.6, Haiku 4.5) is similar in size to cl100k_base. The newer tokenizer in Opus 4.7 and later produces about 1.0–1.35× as many tokens.
  • Google Gemini: an estimated range based on o200k_base, which is similar in vocabulary size to Gemini's SentencePiece tokenizer.

Tokens and context windows

The context window is the most tokens a model can take in one request, counting input and output together. The bar in each row shows how much of that window your text uses. For agents, remember that the system prompt, tool definitions, and every earlier tool result all share the same window, and that context grows with every step. Use the AI Agent Cost Calculator to see how that adds up.

Tips for reducing token usage

  • Trim verbose system prompts and remove examples the model no longer needs.
  • Keep tool schemas short: descriptions and JSON schemas are sent on every call.
  • Return compact tool results (IDs and summaries, not full documents) and let the agent fetch details on demand.
  • Turn on prompt caching for static prefixes. Cached reads cost 2.5–25% of the normal input price, depending on the provider.

Frequently asked questions

How many tokens is a word?

In English, one token is about 4 characters or three-quarters of a word, so 100 tokens is roughly 75 words. Code, numbers, and non-English text usually take more tokens per word.

Why do GPT, Claude, and Gemini give different token counts for the same text?

Each model family uses its own tokenizer with a different vocabulary. OpenAI's current models use o200k_base, Gemini uses a SentencePiece vocabulary, and Claude Opus 4.7 and later use a newer tokenizer that Anthropic says produces up to about 35% more tokens than its previous one for the same text.

Are the Claude and Gemini token counts exact?

No. Anthropic and Google don't publish tokenizers that run in the browser, so this tool shows an estimated range. For exact counts, call Anthropic's count_tokens endpoint or Gemini's countTokens method before sending a request.

Is my text sent to a server?

No. Tokenization runs entirely in your browser with js-tiktoken. Nothing you paste is uploaded or stored.

Do system prompts and tool definitions count toward tokens?

Yes. You're billed for everything the model reads: the system prompt, tool/function schemas, conversation history, retrieved documents, and tool results. Providers also add a few hidden tokens per message and a tool-use system prompt when tools are enabled.

Related reading

More AI builder tools

  • LLM API Cost Calculator — Compare per-request and monthly API costs across OpenAI, Anthropic, and Google models, with prompt caching.
  • LLM VRAM Calculator — Estimate GPU memory for weights, KV cache, and fine-tuning, and see which GPUs a model fits on.
  • AI Agent Cost Calculator — Model the real cost of agent loops: growing context, tool results, prompt caching, retries, and sub-agents.