🍱 Lunchbox Hands

AI Token Counter

Count LLM tokens in your browser with the real o200k_base and cl100k_base encodings

Loading tokenizer…

Cost calculator

Estimates what this prompt costs across LLM APIs, using the token count above as input tokens. Adjust the fields to model your workload.

Model$/MTok in / outCost (1 call)Per 1,000 calls
GPT-5 nanoOpenAI$0.05 / $0.4$0.00020$0.20
Gemini 2.5 Flash-LiteGoogle$0.1 / $0.4$0.00020$0.20
GPT-5.6 LunaOpenAI$0.2 / $1.2$0.00060$0.60
Claude Haiku 4.5Anthropic$1 / $5$0.0025$2.50
Gemini 3.6 FlashGoogle$1.5 / $7.5$0.0037$3.75
GPT-5.6 TerraOpenAI$2 / $12$0.0060$6.00
Gemini 3.1 Pro (preview)Google
Prompts over 200K tokens bill higher ($4 in / $18 out)
$2 / $12$0.0060$6.00
Claude Sonnet 5Anthropic
Intro pricing $2/$10 per MTok through 2026-08-31
$3 / $15$0.0075$7.50
Claude Opus 5Anthropic$5 / $25$0.01$12.50
GPT-5.6 SolOpenAI$5 / $30$0.02$15.00
Claude Fable 5Anthropic$10 / $50$0.03$25.00

Prices as of 2026-08-03 from the providers’ public pricing pages — verify before committing to volume. Sorted cheapest first. ≈ Claude rows use the chars ÷ 3.5 input-token estimate above (Anthropic has no browser tokenizer); Gemini rows apply the GPT token count to Google’s per-token prices, so treat those as ballpark too.

Count exactly how many tokens a prompt costs before you send it: the tool runs the same byte-pair encodings the models use — o200k_base for GPT-4o and the o-series, cl100k_base for GPT-4 and 3.5 — and shows a clearly-labeled approximation for Claude. The token-boundary view highlights each token in place, which is the fastest way to understand why a stray space or an unusual word doubles your count.

The built-in cost calculator turns those counts into money: it prices your prompt against current GPT, Claude, and Gemini API rates — per call and per 1,000 calls, sorted cheapest first — so you can compare providers before you commit to volume. Because Claude has no browser tokenizer, Claude costs inherit the same clearly-labeled estimate as the count above, and Gemini costs reuse the GPT token count; treat both as ballparks and check the exact figures with each provider's count-tokens API before budgeting.

Everything runs locally; prompts never leave your browser. For plain-text metrics the word counter covers characters, words, and reading time, the readability analyzer grades how hard your text is to read, and prompt payloads headed for an API pair well with the JSON formatter.

Frequently asked questions

What is a token?

Language models read text as tokens — chunks produced by a byte-pair-encoding (BPE) tokenizer, each roughly 3–4 English characters or about ¾ of a word. Pricing, context limits, and rate limits are all denominated in tokens, which is why counting them matters before you send a prompt.

Which models do o200k_base and cl100k_base cover?

o200k_base is the encoding used by GPT-4o, GPT-4.1, and the o-series reasoning models. cl100k_base covers GPT-4 and GPT-3.5 Turbo. The same text usually produces slightly fewer tokens under o200k_base because its vocabulary is larger.

Why is the Claude number an estimate?

Anthropic does not publish a client-side tokenizer, so an exact Claude count is not possible in the browser. The tool shows characters ÷ 3.5 as a clearly labeled approximation — good for ballparking cost, not for exact budgeting. For exact numbers use the count-tokens endpoint of the Claude API.

How does the API cost calculator work?

It multiplies your input tokens (the count above, or a manual override) and expected output tokens by each provider’s published per-million-token prices, per call and per 1,000 calls, sorted cheapest first. Prices are copied from the OpenAI, Anthropic, and Google pricing pages on the date shown under the table — they change, so verify against the provider before committing to real volume.

Why are Claude and Gemini costs marked as estimates?

The exact token counts here come from OpenAI’s open-source encodings. Claude rows use the characters-÷-3.5 approximation instead, and Gemini rows apply the GPT count to Google’s prices — both providers tokenize differently, so those costs are ballpark figures. For exact numbers use each provider’s count-tokens API.

Is my text uploaded to count tokens?

No. The tokenizer (the open-source gpt-tokenizer library) runs entirely in your browser — the same BPE algorithm and vocabulary the models use, downloaded once as JavaScript. Your text never leaves the page, so it is safe to paste prompts containing private data.

Why do spaces and capitals change the count?

BPE vocabularies store common words with their leading space, so " hello" and "hello" are different tokens, and rare capitalizations split into more pieces. The token-boundary view highlights exactly where each token starts and ends so you can see these effects directly.

Get weekly dev tools and tips