katlab tools/tokens support on Ko-fi

Token Counter · GPT Tokens & API Cost

Paste a prompt or drop a text file to get the exact token count for OpenAI's o200k_base or cl100k_base encoding, see how the text splits into tokens, and estimate what a request costs.

Tokenized locally in your browser. Your text is never uploaded.

Text

0
Tokens
0
Characters
0
Words
0
Lines
0
Bytes (UTF-8)

Other models estimate

–
Claude Opus 4.7+ / Sonnet 5
–
Claude Sonnet 4.6 / Haiku 4.5 and earlier
–
Gemini

These are not exact counts. Claude and Gemini tokenizers can't be run in the browser, so each range is the o200k_base count × a rough rule-of-thumb ratio: Claude Sonnet 4.6, Haiku 4.5 and earlier ×1.1–1.2; Claude Opus 4.7 and later ×1.4–1.6 (Anthropic says its newer tokenizer produces roughly 30% more tokens for the same text); Gemini ×0.9–1.1. Real ratios vary a lot with language and content. For exact numbers use Anthropic's or Google's token-counting API.

Token view

Each colored span is one token. Spaces show as dots, tabs as →, line breaks as ↵.

Cost estimate

ModelInput tokens$ / 1M in$ / 1M outInput costTotal per request

Input tokens for OpenAI models are the exact o200k_base count of your text; Claude and Gemini rows use the estimate ranges above, so their costs are ranges too. Output tokens are billed at the output price and aren't converted. Standard-tier list prices only: batch, cached-input and regional pricing aren't included, and chat formatting adds a few tokens per message.

How to count tokens for GPT models

Language models don't read characters or words; they read tokens, chunks of text produced by a byte-pair encoder. OpenAI publishes its encoders, so the count here is the real thing: the page loads the same o200k_base or cl100k_base rank table that OpenAI's tiktoken library uses and runs it on your text in the browser. Pick o200k_base for GPT-4o, GPT-4.1, the o1, o3 and o4-mini reasoning models and GPT-5, GPT-5 mini and GPT-5 nano; pick cl100k_base for GPT-4, GPT-4 Turbo, GPT-3.5 Turbo and the text-embedding-3 models. For models not listed, check which encoding the provider documents before relying on the count.

As a rule of thumb, one token is about four characters of English, but code, numbers, non-Latin scripts and emoji take far more tokens per character. The token view makes that visible: each colored span is one token, and turning on token IDs shows the number the model actually receives. Special strings such as <|endoftext|> are counted as ordinary text, the way a chat API treats them in user input.

Why Claude and Gemini counts are estimates

Anthropic and Google don't ship their current tokenizers as something a web page can run, so no browser tool can give you an exact Claude or Gemini count offline, whatever it claims. Instead of pretending, this page shows a range derived from the o200k_base count: ×1.1–1.2 for Claude Sonnet 4.6, Haiku 4.5 and earlier, ×1.4–1.6 for Claude Opus 4.7 and later (Anthropic's pricing page says the newer tokenizer produces about 30% more tokens for the same text), and ×0.9–1.1 for Gemini. These multipliers are rough rules of thumb, not measurements of your text, and the true ratio shifts with language, code density and formatting.

When you need the exact number, before a large batch job or to check you fit a context window, call Anthropic's token-counting endpoint or Gemini's countTokens method. Both are free to call and return the count the model is billed for.

Estimating API cost from a token count

API providers bill input and output tokens separately, and output usually costs four to eight times as much as input. The cost table multiplies the input count by each model's input price per million tokens, then adds your expected output tokens at the output price. Set the output field to a typical response length: a short answer might be 200 tokens, a long code generation several thousand. Reasoning models also bill their hidden reasoning tokens as output, so leave headroom for those.

All prices come from one data object in the page source and carry a visible date. They were checked against the official OpenAI, Anthropic and Google pricing pages on 2026-09-25 and cover standard-tier list prices only. Batch discounts, cached-input rates, long-context surcharges on most models and regional endpoints aren't modeled (Gemini 3.1 Pro Preview's over-200k-token tier is). Treat the result as a budgeting estimate and confirm on the provider's pricing page.

Are the GPT token counts exact?

Yes for the text itself. The page runs OpenAI's published o200k_base and cl100k_base byte-pair encodings (via js-tiktoken), so the count matches OpenAI's tiktoken library. A chat API request adds a few formatting tokens per message on top of the raw text count.

Which encoding should I pick?

o200k_base for GPT-4o, GPT-4.1, o1, o3, o4-mini and the GPT-5, GPT-5 mini and GPT-5 nano models; cl100k_base for GPT-4, GPT-4 Turbo, GPT-3.5 Turbo and the text-embedding-3 models. That is the mapping in OpenAI's tiktoken library.

Why are Claude and Gemini counts only estimates?

Their tokenizers are not available as a library that runs in the browser, so the page multiplies the o200k_base count by a rough ratio and shows a range. For an exact number, use Anthropic's or Google's token-counting API.

How current are the prices?

The price table was checked against the OpenAI, Anthropic and Google pricing pages on 2026-09-25 and that date is shown next to it. Prices change, so confirm on the provider's pricing page before budgeting.

Is my text uploaded anywhere?

No. Tokenization runs in your browser. The only network requests are for the tokenizer rank files, fetched from this site the first time you use an encoding. Your text is never sent anywhere.