How many tokens does your prompt have?

Quickly estimate token counts for Claude, GPT and Gemini — all models side by side, with context window check.

{{ stats.chars }} {{ __t('chars') }} · {{ stats.words }} {{ __t('words') }} · {{ stats.lines }} {{ __t('lines') }} · {{ stats.bytes }} {{ __t('bytes') }}

{{ __t('tokens_per_model') }}
{{ m.name }}
{{ estimateTokens(m).toLocaleString() }}
{{ m.note }}
{{ __t('note_label') }}: {{ __t('disclaimer') }}
{{ __t('context_check') }}
{{ __t('th_model') }} {{ __t('th_tokens') }} {{ __t('th_context') }} {{ __t('th_usage') }} {{ __t('th_status') }}
{{ row.name }} {{ row.tokens.toLocaleString() }} {{ row.context.toLocaleString() }} {{ row.pct.toFixed(1) }}% {{ __t('status_ok') }} {{ __t('status_tight') }} {{ __t('status_over') }}

What are tokens?

Tokens are the building blocks an LLM breaks text into before processing it. A token is usually a word fragment — for English text roughly 4 characters or ¾ of a word; for Chinese/Japanese often 1–2 tokens per character. Tokens drive both cost (billed per million tokens) and capacity (context window in tokens).

Why do counts differ between models?

Each provider trains their own tokenizer on a specific corpus. GPT-4o uses o200k_base (~200k vocab), older GPT cl100k_base (100k). Claude and Gemini have their own tokenizers with different subword splits. The same "internationalization" can be split into 4, 6 or more tokens depending on the tokenizer. Differences are largest for non-Latin scripts (Arabic, Thai, CJK).

Practical tips

  • Rule of thumb: 1 token ≈ 4 chars English, 3 chars German, 1–2 tokens per CJK character.
  • Code and JSON often use more tokens due to special characters — compact notation can save.
  • Long system prompts: enable prompt caching — saves up to 90% of input cost.

How tokenizers really work — BPE, SentencePiece and the CJK effect

A tokenizer is the layer that splits text into the units a language model processes. OpenAI has used Byte-Pair Encoding (BPE) since GPT-2, documented in the tiktoken library. Anthropic uses its own BPE vocabulary for Claude. Google Gemini uses SentencePiece. All three share one core idea: frequent letter sequences merge into one token, rare strings get split into multiple tokens. The word tokenization becomes two tokens in cl100k_base (GPT-4) — token and ization — while strawberry becomes three: straw, berry and the leading-space marker.

Vocabulary size is a key parameter. cl100k_base (GPT-4, GPT-3.5) has 100,256 tokens. o200k_base (GPT-4o, GPT-4o-mini) has 200,019 tokens — nearly double, which makes code, multilingual text and CJK scripts (Chinese, Japanese, Korean) more efficient. Claude (Anthropic) sits between the two and is especially dense for English (shorter strings = fewer tokens). Gemini SentencePiece is tuned for multilinguality: a Japanese sentence often costs 30-40% fewer tokens in Gemini than in cl100k_base.

These differences are not a detail — they directly drive cost and latency. Anthropic, OpenAI and Google bill input and output tokens separately (as of mid-2026). A 50,000-word German document sent to Claude and to GPT-4o typically shows a 10-20% difference on the bill — and at production scale (millions of tokens per day) that matters. The estimator here approximates via chars-per-token factors per model with a CJK-ratio adjustment; for exact counts use the official SDK (tiktoken, anthropic.tokenize_count) or Anthropic's /v1/messages/count_tokens API.

The estimation formula in detail

The tool uses an empirical heuristic that lands within ±10% of the true token count for natural-language text (no code, no base64):

// Per model: two factors
//   chars_per_token   = chars per token in Latin text
//   cjk_chars         = chars per token in CJK text

cjkRatio = (count of CJK codepoints) / (count of all codepoints)
eff      = chars_per_token * (1 - cjkRatio) + cjk_chars * cjkRatio
tokens   = ceil(charLen / eff)

// Factors (as of mid-2026):
// GPT-4o (o200k_base) : chars_per_token = 4.0 , cjk_chars = 1.5
// GPT-4  (cl100k_base): chars_per_token = 3.8 , cjk_chars = 1.4
// Claude              : chars_per_token = 3.5 , cjk_chars = 1.3
// Gemini SentencePiece: chars_per_token = 4.0 , cjk_chars = 1.4

// Rule of thumb for English prose: 1 token ≈ 0.75 words ≈ 4 chars.

Real token counts from practice

Five everyday texts and their typical token size in GPT-4o (o200k_base). Numbers fluctuate ±5% depending on the exact content:

  • A tweet (280 chars English) — about 65-75 tokens. Small enough that a GPT response stays well under 1,000 tokens with context. Important benchmark for high-volume generation (social drafting).
  • One A4 page of prose (~500 words / 3,000 chars) — about 650-700 tokens for English, 750-850 tokens for German (longer compounds produce rarer subwords). An 80-page thesis lands around 55,000 tokens — fits in GPT-4o's 128K context but leaves little room for output.
  • A REST API response as JSON (10 KB) — about 3,500-4,500 tokens. JSON delimiters ({}, [], ",) get dedicated tokens in BPE, which is why JSON is denser than YAML but looser than plain prose. For function-calling workflows: don't dump the whole dataset, filter in code first.
  • 500 lines of Python code (~15 KB) — about 5,000-7,000 tokens. Code is not as token-efficient as prose: variable names, indentation, closing brackets all eat tokens. A mid-sized class plus tests still fits easily into Claude Sonnet's 1M context — you can pass the whole module instead of sending RAG snippets.
  • A Japanese Wikipedia paragraph (1,000 CJK chars) — in Gemini SentencePiece about 700 tokens, in GPT-4 cl100k_base about 900-1,100 tokens, in GPT-4o o200k_base about 650-800 tokens. For Japanese/Chinese workloads, model choice is also a cost choice: 30% fewer tokens = 30% lower bill.

What this estimate cannot do

The heuristic is an approximation, not an exact counter. Three cases where it is systematically off: (1) code with many rare tokens — minified JavaScript, long hash strings, base64 blobs often need 1.5x more tokens than the rule of thumb gives. (2) images, audio, PDF attachments — multimodal models (GPT-4o, Claude Sonnet, Gemini) bill images as fixed token sums per resolution (e.g. ~765-1100 tokens for a 1024x1024 image in GPT-4o depending on detail). This is a text-only tool. (3) tool calls and function schemas — the JSON schemas you pass in tools=[] count too, often 1,000+ tokens per call. For exact billing: the official counters (OpenAI tiktoken, Anthropic /v1/messages/count_tokens) are authoritative. This estimate is for "does it fit in the context?" and capacity planning.

Frequently asked questions

How accurate is this token estimate?
For natural language (English, German, Spanish, French) it is typically within ±5-10% of the real count. For code, JSON and base64 it tends to underestimate slightly. For CJK the magnitude is right but specific models can deviate. For exact billing use the official tokenizers — OpenAI tiktoken (Python/JS), Anthropic /v1/messages/count_tokens, Google Vertex countTokens.
Are the token counts for GPT-3.5 and GPT-4 identical?
Yes — both use the cl100k_base vocabulary. GPT-4o and GPT-4o-mini instead use o200k_base and typically need 5-15% fewer tokens for the same input. Migrating an old GPT-3.5 app to GPT-4o means you cannot reuse the token estimate 1:1.
What counts toward the context window — only my input or also the response?
All of it. The context window (e.g. 128K for GPT-4o, 200K or 1M for Claude Sonnet 4.5, 1M for Gemini 2.0 Flash) is the maximum total of system prompt + conversation history + current user input + generated response. For longer conversations sum output tokens (max_tokens) and input tokens together to stay below the limit.
How many words are 1,000 tokens?
For English about 750 words, for German more like 600-700 (longer words, more subwords), for French and Spanish 750-800, for Japanese 500-700 CJK characters. Rough rule: "1,000 tokens = 1 page of a book in standard layout".
Is my text sent anywhere?
No. Counting runs entirely in the browser as a JavaScript heuristic. No API call, no logging, no analytics sees the content. You can verify in DevTools (Network tab) — no request fires on typing. Real tokenization with the official tokenizers would require server calls; this tool deliberately avoids that.
How do I reduce token usage and cost?
Five levers ranked by impact: (1) Prompt caching for reused system prompts — Anthropic and OpenAI bill cache hits at 10% of normal input price. (2) RAG instead of full context — don't pass 500 pages of docs, vector-search the 5 relevant paragraphs. (3) Pick a smaller model where possible: GPT-4o-mini, Claude Haiku, Gemini Flash are 5-10x cheaper than the big ones. (4) Cap max_tokens — answers rarely fill the default. (5) Compact JSON: a schema with short keys saves 20-30%.

Related tools