Claude Token Counter
Count tokens for Anthropic's Claude models (Opus 5.5, Sonnet 5.5, Opus 4.7, Sonnet 4.6, Haiku 4.5) with
cost estimates against Anthropic's list prices. Anthropic doesn't ship a JavaScript tokenizer, so this is a
heuristic estimate, not an exact count: use the official /v1/messages/count_tokens endpoint
when you need billing-grade numbers. Note that models from Claude Opus 4.7 on use a newer tokenizer that
fits about 555k words in 1M tokens, versus about 750k words on earlier models (Anthropic models overview).
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 5.5 | $4.00 | $20.00 | $0.20 | $0.024 |
| Claude Sonnet 5.5 | $2.00 | $10.00 | $0.10 | $0.012 |
| Claude Opus 4.7 | $5.00 | $25.00 | $0.50 | $0.030 |
| Claude Sonnet 4.6 | $3.00 | $15.00 | $0.30 | $0.018 |
| Claude Haiku 4.5 | $1.00 | $5.00 | $0.10 | $0.006 |
Prices are Anthropic's list prices per million tokens (checked 2026-11-12 on platform.claude.com). Opus 5.5 costs twice Sonnet 5.5 per token; Haiku 4.5 is the cheapest of these and the fastest. Cache hits cost 10% on Opus 4.7, Sonnet 4.6 and Haiku 4.5 and 5% on Opus 5.5 and Sonnet 5.5 of the base input price. 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 minimum cacheable prompt is 1,024 tokens for Sonnet 4.6 and 512 for Sonnet 5.5, so shorter 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 4.6 and later models include the full 1M-token context at standard pricing, so per-call cost 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.