AI Token Counter
Count tokens and estimate costs for GPT, Claude, Gemini, and more. Runs entirely in your browser.
What it counts
Paste text, pick a model, and get the token count plus what the call would cost at that model's rates. The tokeniser runs in your browser, so the text never leaves the page.
Tokens are not words and not characters. English prose averages around 1.3 tokens per word, code is considerably worse, and languages that do not use spaces are worse again. That is why guessing from a character count is unreliable at exactly the moment it matters, which is when you are close to a context limit.
More detail
Exact counts and estimates are not the same thing
For the Claude models and for o3 and o4-mini the count is exact, because a real tokeniser for them runs locally in the page. What you see is what the API will bill you for, give or take the framing described below.
Everything else is an estimate, including GPT-5.4. Those models publish no local tokeniser, so the count is produced with a stand-in encoding: o200k_base for the OpenAI, Google, xAI and DeepSeek models, and the Claude vocabulary for the Llama ones. That is close on ordinary English prose and drifts on code, on CJK text and on unusual formatting. Each model page says which of the two it is rather than presenting every number as authoritative.
What the number leaves out
Your system prompt, unless you paste it in as well. It is billed as input on every single turn.
Tool definitions. A handful of tools with detailed JSON schemas can add thousands of input tokens to every request, and this is the line item that surprises people most.
Per-message framing, images, audio and cached reads. Images in particular are billed on their own rules that this does not model.
Treat the result as a floor for input. Measure your own fixed overhead once by comparing a real API response's reported usage against this page for the same message body; it is constant, so you only have to do it once.
Using it to choose a model
Costs differ by more than an order of magnitude across the models here, and the input-to-output ratio differs too. For chat and agent workloads the bill is usually driven by how much the model writes rather than how much you send, which means trimming your prompt is often the wrong optimisation and capping output length is the right one.
Count the same prompt against two candidates and compare the totals before committing to the expensive one.
Questions
Does my text get sent anywhere?
No. The tokeniser vocabulary is bundled into the page and the encoding runs in your browser. Disconnect from the network and it still works.
Why does the API report a different number than this?
Almost always the system prompt or the tool definitions, neither of which is in the text you pasted. Compare a real response's reported input usage against this page for the same message body and the difference is your fixed per-request overhead.
Which counts are exact and which are estimates?
The Claude models, o3 and o4-mini are counted with a real tokeniser and are exact. Everything else, GPT-5.4 included, is estimated with a stand-in encoding because no local tokeniser is published for it. Each model page states which applies.
How many tokens is a page of code?
Expect roughly 300 to 450 tokens for a 60-line TypeScript file. Code tokenises worse than prose because punctuation, indentation and identifiers fragment into many small tokens. Minified code is worse still.