LLM token counter

Count prompt tokens with o200k_base, compare model pricing and context limits, and estimate input/cached/output cost in your browser.

Tokens

...

Words

0

Characters

0

Swipe table for all columns.

ModelProviderCtxIn /1MCache /1MOut /1MIn $Cache $Out $
gpt-4oOpenAI128K$2.50$1.25$10.00
gpt-4o-miniOpenAI128K$0.150$0.075$0.600
gpt-5.5OpenAI1.05M$5.00$0.500$30.00
gpt-5.5-proOpenAI1.05M$30.00$180.00
gpt-5-codexOpenAI400K$1.25$0.125$10.00
gpt-5.1-codex-miniOpenAI400K$0.250$0.025$2.00
o3OpenAI200K$2.00$0.500$8.00
o4-miniOpenAI200K$1.10$0.275$4.40
claude-sonnet-4.6Anthropic1M$3.00$0.300$15.00
claude-opus-4.8Anthropic1M$5.00$0.500$25.00
claude-fable-5Anthropic1M$10.00$1.00$50.00
claude-haiku-4.5Anthropic200K$1.00$0.100$5.00
gemini-3.5-flashGoogle1.05M$1.50$0.150$9.00
gemini-3.1-pro-previewGoogle1.05M$2.00$0.200$12.00
gemini-3.1-flash-lite-previewGoogle1.05M$0.250$0.025$1.50
grok-4.3xAI1M$1.25$0.200$2.50
grok-4.20xAI2M$1.25$0.200$2.50

Token counts use o200k_base (tiktoken). OpenAI models are exact on this encoding; other providers are approximate. Price columns apply your token count to each model's input, cached-input, and output rates. Pricing via OpenRouter (updated Jun 11, 2026). Rows highlighted in red exceed that model's context window. Counts run in your browser; your text is not uploaded.

What is a token?

A token is the unit an LLM reads and generates. Tokenizers split text into subword pieces before inference, so one visible word can map to one token or multiple tokens depending on spelling, punctuation, and language.

A common rough estimate is about four characters per token in English prose, but code, URLs, and multilingual text can vary widely. For planning accuracy, count the real prompt instead of relying on word-count rules.

Why count tokens before you call an API?

LLM APIs bill by tokens, often with separate rates for input, cached-input, and output. Counting first helps you forecast request cost before deployment and avoid hidden spend from large system prompts and repeated RAG context.

Each model also enforces a context window cap. Long conversations, retrieved chunks, tool instructions, and the latest user message all compete for the same token budget.

How this token counter works

This page tokenizes with OpenAI's o200k_base encoding in-browser via js-tiktoken. Counts are exact for models that use that encoding and planning-level estimates for providers with different tokenizers.

The pricing table applies your current token count to model rates for input, cached input, and output. Catalog data is synced from OpenRouter, and each row can be filtered by model or provider for quick comparisons.

Rows turn red when your token count is above that model's listed context window. This catches likely overflow before you send API requests.

Accuracy boundaries and privacy

Local text tokenization does not include full API payload overhead such as tool schemas, image/file inputs, or provider-specific request wrappers. For billing-critical checks, validate against each vendor's official counting endpoint or tokenizer.

Your text stays in your browser. Nothing is uploaded, logged, or stored on our servers.

Model pricing and context planning

Use the table to compare context limits and per-million token rates on the same prompt size. Cached-input columns assume your repeated prefix qualifies for provider caching discounts.

The catalog includes fast-moving releases when available, including newer Anthropic lines such as Claude Opus 4.8 and Claude Fable 5, so you can benchmark likely cost before rollout.

Output-price estimates are scenario calculations, not actual completion totals. Real request cost depends on prompt tokens plus the response tokens generated at runtime.

Model prices and context limits can change. Treat table values as planning references and confirm production budgets in provider docs.

Frequently asked questions

How many tokens is 1,000 words in OpenAI GPT models?

For English prose on OpenAI's o200k_base tokenizer (used by GPT-4o, GPT-4o mini, o-series, and GPT-5.x on that encoding), 1,000 words is often roughly 1,300 to 1,400 tokens. Code, Markdown tables, and heavy punctuation usually raise that ratio because symbols and rare strings split into more tokens.

How do you calculate LLM API costs from token counts?

Providers charge per million input tokens and per million output tokens. The pricing table multiplies your pasted token count by each model's listed rates for input, cached input, and output. For a full call, add (prompt tokens ÷ 1,000,000 × input or cached rate) plus (completion tokens ÷ 1,000,000 × output rate). The output columns show cost only if your entire paste were output tokens; estimate completion length separately. System prompts and RAG context count on every call if you resend them.

Which models is this token count exact for?

Counts are exact for models that use OpenAI's o200k_base encoding. They are not exact for models on other tokenizers, including older OpenAI cl100k_base families and many non-OpenAI providers. For invoice-level validation, use the vendor's official counter.

Where do model prices and context limits come from?

Rates and context windows are synced from OpenRouter into a local catalog and shown in the table. They are estimates for comparing models, not guaranteed invoice amounts. Providers change pricing and limits without notice; confirm before you budget or ship. The sync date appears below the table when available.

Why is a model row highlighted in red?

A red row means your current token count exceeds that model's listed context window in our catalog. The API may reject the request, truncate input, or drop older turns depending on the provider. Shrink the prompt, split the job, or pick a model with a larger context limit.

Why might Claude or Gemini costs differ from my bill?

This page tokenizes with o200k_base (OpenAI's encoding). Claude and Gemini use their own tokenizers, so the same text can produce a different token count on their APIs. The table multiplies your o200k_base count by OpenRouter-listed rates for those models, which is useful for rough comparison but not a substitute for each vendor's official token counter when you need exact billing.

How should I estimate Claude Fable 5 token cost?

Select the Claude Fable 5 row in the pricing table and apply your prompt token count to input, cached-input, and output columns. This gives a planning estimate for Fable calls, but because Anthropic uses its own tokenizer, validate final billing-critical numbers with Anthropic's official token counting flow before launch.

Why can API-reported token usage be higher than this page?

API usage may include extra tokens beyond raw text, such as tool schemas, structured output constraints, images, files, and provider-specific wrappers. This tool is best for prompt-size planning; use provider token-count endpoints for full payload accounting.

Why does source code consume more tokens than plain text?

Tokenizers are trained heavily on natural language. Source code packs in braces, operators, indentation, and rare identifiers that often split into several sub-tokens each. A line of code can cost noticeably more tokens than a line of prose; paste the real file here instead of guessing from word count.

Do non-English languages use more tokens to process?

Often yes. Many tokenizers assign fewer single-token words to non-Latin scripts (for example Arabic, Hindi, Japanese, or Chinese), so one visible word may become several tokens. The multiplier varies by language and text. Paste translated or multilingual copy here to measure o200k_base size for OpenAI prompts.

What is a context window, and what happens when it fills up?

A context window is the maximum tokens one API call can include: system prompt, history, retrieved chunks, tools, and the new user message. Over the limit you may see errors, truncated replies, or dropped older turns. Very long prompts can also hurt recall in the middle of the context on some models. Count everything you plan to send, not just the latest message.

How do tokens relate to prompt caching in Claude or OpenAI?

Prompt caching lets providers reuse identical prefix text (large system prompts, docs, or code summaries) on later requests at a lower cached rate when your payload structure qualifies. Providers define minimum sizes and layout rules. Use this counter to measure those static blocks, then compare the Input and Input (cached) columns in the table to see estimated cost for uncached versus cached input at your token count.

Is it safe to paste proprietary code or system prompts here?

Yes. Tokenization runs in your browser with js-tiktoken; your text is not uploaded, logged, or stored on our servers. You can size internal system prompts, customer data, or code samples without sending them to us.

What is the difference between tokens, words, and characters?

Characters are letters, digits, and symbols. Words are human units split on whitespace. Tokens are model-specific BPE pieces; one word may be one token or many. This page counts o200k_base tokens for OpenAI API sizing and shows words and characters alongside. For sentences, paragraphs, and reading time, use the word counter on this site.

Explore all tools