Claude Token Counter
Count tokens for Anthropic's Claude models — Opus 4.7, Sonnet 4.6, Haiku 4.5, Claude 3.5 Sonnet — with
cost estimates against current API pricing. Anthropic doesn't ship a JavaScript tokenizer, so this uses
a calibrated heuristic that matches the official /count_tokens endpoint within ~5% for
English. Runs in your browser; text never leaves the page.
How to use the Claude Token Counter
Paste any text, pick the Claude variant you'll be calling, and press Count tokens. The tool returns the token count, character count, and (with cost enabled) per-call, monthly, and annual cost projections based on Anthropic's current API list pricing.
For production workloads where exact billing matters, hit Anthropic's
/v1/messages/count_tokens
endpoint instead — same request shape as /messages, just returns the token count without
running the model. That endpoint is free. For pre-flight sizing where you haven't built the API client
yet (or you don't want to paste production data through an API call), this tool is the faster path.
What is Claude's tokenizer
Claude uses a SentencePiece-style Byte Pair Encoding tokenizer with a vocabulary in the range of
~150K tokens. Anthropic hasn't published the exact vocabulary or made it available as a public
library (unlike OpenAI's tiktoken), so direct in-browser tokenization isn't possible
without an API call.
Empirically, Claude's tokenizer behaves similarly to GPT-3.5's cl100k_base for English
text — about 4 characters per token on average. It's slightly looser (more tokens) than
o200k_base used by GPT-4o and GPT-5. For code, especially with single-character
identifiers and dense punctuation, Claude is in the same ballpark as cl100k_base. For non-Latin
scripts (Mandarin, Hindi, Arabic), Claude's tokenizer can produce 1.5-2x more tokens than
o200k_base, which matters for multilingual cost analysis.
Pricing comparison across the Claude line
For 1,000 tokens of input + 1,000 tokens of output, the per-call cost works out to:
| Model | Input ($/M) | Output ($/M) | Cached ($/M) | Per-call (1K + 1K) |
|---|---|---|---|---|
| Claude Opus 4.7 | $15.00 | $75.00 | $1.50 | $0.090 |
| Claude Sonnet 4.6 | $3.00 | $15.00 | $0.30 | $0.018 |
| Claude Haiku 4.5 | $1.00 | $5.00 | $0.10 | $0.006 |
| Claude 3.5 Sonnet (legacy) | $3.00 | $15.00 | $0.30 | $0.018 |
Opus is 5x the cost of Sonnet for similar quality on most tasks; reserve it for the genuinely hard problems. Haiku is 3x cheaper than Sonnet and noticeably faster — a good default for high-volume classification, routing, and shorter generation. Cached pricing applies only to input tokens that match a previously-cached prefix; it does not discount output.
Common use cases
- System prompt sizing. Pasting a Sonnet system prompt to see whether it fits in the cacheable prefix (the 1024-token minimum for Sonnet means short prompts don't benefit from prompt caching at all).
- RAG chunk planning. Counting your average retrieved chunk to size a top-k retrieval that fits the model's context without wasting it.
- Comparing Claude to GPT. Same text into both this tool and the OpenAI Token Counter to see where the per-token-cost difference goes once tokenization is accounted for.
- Pre-flight budget for a migration. If you're moving a workload from GPT-4o to Claude Sonnet, the token-count delta plus the per-token price delta gives you the real monthly cost change.
- Long-context cost estimation. Claude's 200K context isn't tiered like Gemini's, but per-call pricing scales linearly. A 150K-token input on Sonnet 4.6 costs $0.45 per call before output. Knowing the count up front avoids surprises.
Frequently asked questions
Why is this an estimate and not the exact Anthropic count?
How do Claude tokens differ from OpenAI tokens for the same text?
o200k_base) for the same English text, and roughly the same as GPT-3.5's cl100k_base. For code and non-English text the difference is larger. Use the Multi-Model Token Comparison tool to see the side-by-side.