Claude Token Counter: Estimate Tokens and Cost Online
Count Claude tokens in your browser, see what a prompt costs on Opus, Sonnet and Haiku, and learn when you need Anthropic’s exact count instead.
You have a system prompt for Claude that keeps growing, and before you ship it you want two numbers: how many tokens it is, and what each call will cost. Anthropic bills by the token. It does not, however, give you a tokenizer you can run on your own machine.
So you have two options. A fast estimate that never leaves your browser, or an exact count from Anthropic’s API. Below is how to get each, and which one to trust when.
How to count Claude tokens online
Open the Token Counter, paste your prompt and read the four Claude rows: Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 4.5. Each row shows the token count, the input cost, the total cost with the reply you reserved, and how much of the context window is left. The counting runs in your browser, so nothing is sent to Anthropic or to us.
Try it with the tool’s built-in sample, a 363-character support-email prompt (65 words), and reserve 500 output tokens. Opus 5.5, Sonnet 5.5 and Fable 5.1 show 139 tokens and Haiku 4.5 shows 106, each with an “estimate” badge. GPT-4o shows 84, with no badge, because OpenAI publishes that tokenizer and the count is exact. Pick Claude Opus 5.5 in the model menu and turn on Exact Anthropic count, and the tool asks Anthropic instead: 136 tokens.

Why a Claude token count is an estimate
A tokenizer splits text into pieces from a fixed vocabulary, and every model family has its own vocabulary. OpenAI publishes its encodings as open source, so a browser tool can run the real GPT-4o tokenizer and get the exact number. Anthropic hasn’t published a tokenizer for current Claude models, so no browser tool can reproduce Claude’s splits exactly.
The Token Counter starts from cl100k_base, an older OpenAI encoding, as a stand-in, then corrects it with numbers we measured against Anthropic’s exact counts on 16 test texts (prose, code, JSON, Markdown, five languages, emoji) on 2026-10-12. Two things mattered. Anthropic adds about 10.6 tokens to wrap any text as a message, and on Opus, Sonnet and Fable, Latin-script text costs 1.49 times the stand-in while Persian, Chinese and Japanese cost 0.80 times. With those corrections the estimate was off by 8.1% on average across the 16 texts, and by 19.8% at worst. Good enough to plan and compare, not to promise a figure to finance.
One more reason for headroom: Anthropic’s token counting docs (checked 2026-10) say Claude 4.7 and later models, Fable 5.1 among them, use a newer tokenizer that turns the same text into roughly 30 percent more tokens than earlier Claude models did. Counts you measured on an older model don’t carry over, so recount against the model you will actually call.
What changes the Claude token count
Character count is a poor guide on its own. Under the stand-in tokenizer the estimate starts from, a plain English instruction comes to 19.6 tokens per 100 characters, while a short Python function needs 29.9. This Python function needs 1.5× as many tokens per character as the English instruction, because brackets, underscores and type hints break into many small pieces.
Tokens per 100 characters, stand-in tokenizer (cl100k_base)
| Value | |
|---|---|
| English request | 19.6 tokens |
| Spanish request | 24.1 tokens |
| Python function | 29.9 tokens |
| JSON tool schema | 29 tokens |
Four samples of about 140 characters each. Python and JSON tool definitions cost about 1.5 times as many tokens per character as an English instruction.
Calculated with the same logic as our Token Counter & Cost Calculator: GPT, Claude, Gemini, DeepSeek and more.
The same request in Spanish lands at 24.1, and a JSON tool definition at 29.0. Anthropic’s exact counts on our test texts keep the main point: Python and TypeScript cost more tokens per character than English prose. That matters if you use tool use: every tool schema you attach is sent as input on every call, so a handful of detailed tools can outweigh the question you are actually asking.
When you need the exact count from Anthropic
Anthropic’s Messages API has a token counting endpoint (POST /v1/messages/count_tokens). You send the same payload you would send to create a message, including the system prompt, tools, images and PDFs, and it returns the input token count without running the model. Anthropic’s docs (checked 2026-10) describe it as free to use, with its own per-minute rate limits, and say the count is itself an estimate: the input tokens a real request uses can differ by a small amount. The Token Counter’s Exact Anthropic count switch calls this endpoint for you. Amazon Bedrock added a Count Tokens API for Claude models in August 2025.
The catch is that your text goes to Anthropic, which is why the switch is off by default. In production code that is fine, since you are about to send it anyway. For a draft that still has a customer’s name and order history in it, I’d rather count locally first, and redact personal information before it goes anywhere.
Estimate in the browser while you write and trim the prompt. Then, in your app, call count_tokens on the final request before sending anything large enough to come close to the context window.
What a Claude prompt costs (prices as of October 2026)
Per million tokens, Anthropic’s pricing page (checked 2026-10-04) lists Claude Haiku 4.5 at $1 input and $5 output, Sonnet 5.5 at $2 and $10, Opus 5.5 at $4 and $20, and Fable 5.1 at $10 and $50. Output always costs five times the input rate.
That ratio is why, for a short prompt like this one, the reply decides the bill. For the sample prompt with 500 output tokens reserved, using Anthropic’s exact count (136 tokens), Opus 5.5 comes to $0.0105 per call, and only $0.00054 of that is the prompt itself. Haiku 4.5, at 97 exact tokens, does the same call for $0.00260. Trimming a short prompt barely moves the number, while capping the reply length or picking a smaller model does. Cutting LLM API costs goes deeper on both.
Context is rarely the problem at this size. Fable, Opus and Sonnet have a 1,000,000-token window, so the sample leaves 999,364 tokens free. Haiku 4.5 has 200,000, leaving 199,403. If you are pasting whole contracts or codebases, though, check the fit column before you check the price.
Habits that keep Claude estimates useful
- Reserve the reply you actually expect. The total cost column assumes the model writes that many tokens.
- Count the whole request, not just the question: system prompt, conversation history and tool schemas all go in as input.
- Leave generous headroom near a context limit, since the Claude number is an estimate.
- Look at the “pricing as of” date under the table. Prices change, and the tool says when they were last checked.
If you want to see where the token boundaries actually fall in your text, the visual guide to how GPT tokenizes text shows the splits piece by piece.
Mahdi Moradi
Full-stack software engineer and founder of Bornara AI, building free privacy-first tools at ZipTools. Based in Calgary, Canada.
Try the tool mentioned in this article.
Open token counterRelated articles
How AI Background Removal Works — The Technology Behind Instant Cutouts
Neural networks can separate foreground from background in seconds. Here's how the technology works, why client-side processing matters, and how to get the best results.
WebP vs AVIF vs PNG vs JPEG: Which Format to Use (Tested)
We ran a real photo and a screenshot through every format and quality level. WebP won both, PNG grew, and AVIF needs more than a browser to make.
How AI Reads Your Text: Tokens, Costs, and Context Windows Explained
Language models do not read words — they read tokens. Understanding tokens is the key to predicting what an AI request will cost and whether your prompt will even fit. Here is how it works, in plain English.