Live token counting, context-window usage, API cost forecasting and prompt optimization — for every Claude model.
Runs 100% in your browser Offline estimate + optional official API mode Your text never leaves this tab unless you opt in
1. Model & mode
Claude model
Input format
Counting mode
Speed
—
Anthropic API key (kept in memory only, never uploaded by this tool except directly to api.anthropic.com)
Official mode calls Anthropic's /v1/messages/count_tokens endpoint directly from your browser. Some networks/CORS policies may block this; if it fails, the tool falls back to the offline estimate automatically.
2. Add your content
📄
Drag & drop a file, paste, or type below
TXT, Markdown, JSON and PDF (text extracted client-side) are supported
.txt · .md · .json · .html · .pdf
Ignore extra whitespace Ignore code comments Ignore Markdown syntax Ignore HTML tags Count visible text only
No System:/Human:/Assistant: style sections detected — treating the whole input as a single user turn.
5. Token breakdown
6. Export
Model rates (editable — defaults reflect Anthropic's published July 2026 list prices; verify at docs.claude.com)
This request
Model
Input tokens
Output tokens
Requests / day
Cost breakdown
Forecast
Working days / month
Monthly budget (USD)
Compare across Claude models (same token counts)
Uses the text from the Estimate tab. Non-Claude figures are indicative approximations based on publicly reported tokenizer behavior and pricing — always confirm with each provider before budgeting.
Tokenization & context comparison
Estimated cost for this input (typical mid-tier model per family)
Simulate a multi-turn conversation
Model
System prompt tokens
Avg. user turn tokens
Avg. assistant turn tokens
Number of turns
Results
Uses the text from the Estimate tab. Cleanup runs entirely client-side and never modifies your original input unless you copy the result back.
Quality signals
Before / after cleanup
Original
Optimized
Repeated sentences & duplicate paragraphs
Most expensive sections
Saved & recent calculations
Nothing saved yet. Use "Save to history" on the Estimate tab — everything is stored only in this browser's local storage.
Claude Token & Cost Estimator: Free Online Calculator
Working with Claude's API means paying close attention to tokens —
the units that determine both how much of a model's context window you're using and
how much a request costs. Our Claude Token & Cost Estimator is a
free, browser-based tool that helps developers, prompt engineers, and teams estimate
token counts, forecast API spend, and optimize prompts before they ever hit the API.
What This Tool Does
Live token counting for any text, code, JSON, Markdown, or HTML input, with an optional official API mode that calls Anthropic's own count_tokens endpoint for an exact number.
Cost calculator covering input/output pricing, prompt caching (read and write), and Batch API discounts across every current Claude model.
Model comparison to see how token counts and context-window usage differ across Claude, GPT-class, Gemini-class, and Llama-class models.
Conversation growth simulator that projects how a multi-turn chat's token usage and cost accumulate over time, including the effect of prompt caching.
Prompt optimizer that flags duplicate sentences, repeated paragraphs, and excess whitespace, then estimates how many tokens — and how much money — cleanup can save.
Exportable reports in TXT, JSON, and CSV, plus local history and favorites for tracking past estimates.
Why Token Counting Matters
Claude models don't process text word by word — they process it in tokens,
which are often word-pieces, whole short words, or punctuation marks. Because API pricing is
billed per token and every model has a fixed context window, knowing your token count in
advance helps you avoid unexpected costs, prevent context-window overflow errors, and design
more efficient prompts.
How the Estimate Is Calculated
In offline mode, the tool approximates token counts using a blended
character-and-word heuristic, adjusted for code density, and is typically within roughly
10–15% of the true count for ordinary English prose. In official API mode,
it calls Anthropic's /v1/messages/count_tokens endpoint directly from your
browser using your own API key, returning an exact count for your selected model.
Who It's For
Developers budgeting API usage before shipping a Claude-powered feature
Prompt engineers optimizing system prompts and RAG context for cost and length
Teams forecasting monthly or annual LLM spend across different models
Anyone comparing token efficiency and pricing across Claude, GPT, Gemini, and Llama
Privacy
Everything runs locally in your browser by default. Your text is never uploaded anywhere
unless you explicitly enable official API mode, which sends only the text needed for that
one count request directly to Anthropic's API using your own key. History and favorites are
stored only in your browser's local storage and can be cleared anytime.
Frequently Asked Questions
How accurate is the offline token estimate?
The offline estimate is a heuristic, not Anthropic's real tokenizer. For ordinary English prose it's typically within roughly 10–15% of the actual count. For an exact figure, switch to official API mode, which calls Anthropic's count_tokens endpoint directly.
Do I need an API key to use this tool?
No. Offline estimation works with no key and no account. An API key is only required if you switch to official API mode for an exact, model-verified token count.
Is my text or API key ever uploaded anywhere?
By default, no — all calculations run locally in your browser. Your text is only sent over the network if you enable official API mode, in which case it goes directly to Anthropic's API, not to any third-party server.
What is a token, roughly, in plain terms?
A token is the basic unit a language model reads and writes — often a whole short word, a piece of a longer word, or a punctuation mark. As a rough rule of thumb for English text, 1 token ≈ 4 characters ≈ 0.75 words.
Which Claude models does the calculator support?
It covers the current Claude lineup — Haiku 4.5, Sonnet 5, Opus 4.8, and Fable 5 — with editable pricing so you can update rates if Anthropic's published pricing changes.
Can I estimate the cost of a full multi-turn conversation, not just one prompt?
Yes. The Conversation Growth tab simulates how token usage and cost accumulate across multiple turns, including the effect of prompt caching on repeated context.
How does prompt caching affect cost?
Cached reads are billed at a steep discount compared to standard input tokens, while cache writes carry a modest premium. The Cost Calculator lets you toggle cache-read and cache-write assumptions to see the effect on price.
Can this tool help me shorten a prompt to save money?
Yes. The Optimize tab detects duplicate sentences, repeated paragraphs, and excess whitespace, then shows a before/after comparison with the estimated token and cost savings from cleanup.