Free tool
Claude token counter
Approximate token counts for Claude Opus, Sonnet, and Haiku. Anthropic doesn't ship an offline tokenizer, so this uses a char-based estimate within ±10% of the real count.
Claude
~0
approx (±10%)
Characters
0
Words
0
What is a token?
Anthropic's Claude models (Opus, Sonnet, Haiku across the 3.x and 4.x families) use a proprietary tokenizer that Anthropic does not publish. The only way to get an exact token count is to call the messages.countTokens API endpoint, which requires an API key and a network roundtrip.
This tool uses a calibrated character-based heuristic (chars ÷ 4) that's accurate to within about ±10% for typical English prose. Anthropic themselves recommend against using the legacy @anthropic-ai/tokenizer npm package — it's a Claude-2-era BPE table and is meaningfully wrong for modern Claude models.
If you need an exact count (for a bill audit or a production budget cap), use Anthropic's free countTokens endpoint. For quick estimation or UX previews, this heuristic is close enough.
Heads-up: Claude Opus 4.7 shipped with a retrained tokenizer that emits 1.0-1.35× more tokens than Opus 4.6 on the same text. That's not captured in this counter — it affects pricing but not the count you see here.
How tokens relate to characters
| Text | Characters | ~Tokens |
|---|---|---|
| Hello | 5 | 1 |
| Hello, world! | 13 | 4 |
| The quick brown fox jumps over the lazy dog. | 44 | 11 |
| function add(a, b) { return a + b; } | 36 | 13 |
| pneumonoultramicroscopicsilicovolcanoconiosis | 45 | 11 |
| 🎉🚀✨ emoji counts are surprising | 30 | 12 |
Frequently asked
Why is the Claude count only approximate?
Anthropic doesn't publish their tokenizer. The only exact count comes from calling the countTokens API, which needs a network roundtrip. For a browser-side counter, a character-based heuristic is the practical choice — it's accurate to about ±10% for English prose.
How accurate is the chars÷4 heuristic?
Very accurate for English prose (±10%), less accurate for code (it slightly under-counts), and much less accurate for non-English scripts. For Chinese, Japanese, and Korean, Claude typically produces 2-3× more tokens per character than English.
Does Opus 4.7 really tokenize differently?
Yes. Anthropic shipped a retrained tokenizer with Opus 4.7 that emits 1.0-1.35× more tokens than Opus 4.6 on identical input. We apply a 1.15× multiplier to Opus 4.7 cost estimates elsewhere in Calcis to reflect this. This counter doesn't — assume your real bill with Opus 4.7 will be roughly 15% higher than the count shown here.
Should I use the @anthropic-ai/tokenizer npm package?
No. Anthropic explicitly recommends against it. That package is a Claude-2-era BPE vocabulary that doesn't match any modern Claude model. A simple char-based heuristic is actually more accurate than the legacy tokenizer for Claude 3+.
How do I get an exact Claude token count?
Call Anthropic's messages.countTokens endpoint with the model ID. It's free and returns the exact count you'll be billed for. The Calcis /estimator does this automatically when you paste a prompt.
Know the tokens? Get the cost.
Once you've got a token count, the estimator turns it into an exact dollar forecast across every model.