Estimate Claude API tokens and cost from any text

Paste a prompt, document, or transcript below. This runs entirely in your browser and gives a live token estimate plus what it would cost on Claude Opus 4.8, Sonnet 4.6, and Haiku 4.5 — including prompt-cache write and read pricing.

The model's reply length. Output is priced higher than input.
Applies only to the input tokens.
Multiply the per-call cost by this.
0
Characters
0
Words
0
Input tokens (est.)
0
Output tokens
ModelIn $/1MOut $/1MInput costOutput costTotal

How this token estimate is calculated

The official way to count Claude tokens is the API count_tokens endpoint, which uses the exact model tokenizer — but that needs a network call and an API key. This page gives a fast, fully-offline approximation instead, so you can ballpark cost before you ever send a request.

Claude's tokenizer (the one shared by Opus 4.7, Opus 4.8, and Fable 5) breaks text into sub-word pieces. English prose averages roughly four characters per token, but pure character count overshoots on whitespace-heavy or repetitive text and undershoots on code, punctuation, and non-English scripts. To stay close across mixed inputs, this tool blends two signals — a character-based estimate and a word-based estimate — and takes the higher of the two, which tracks real Claude counts better than either alone:

tokens ≈ max( characters ÷ 3.85 , words × 1.33 ) + punctuation_marks × 0.20

The ÷ 3.85 divisor is slightly tighter than the popular "4 characters per token" rule because Claude's tokenizer splits punctuation and code symbols into their own tokens, nudging the real count up. The word multiplier of 1.33 reflects that the average English word is a little over one token once suffixes and spaces are accounted for, and the small punctuation term captures dense JSON or Markdown. This is an estimate, not a guarantee — expect it to land within about 10–15% of the API count for typical English, with wider variance on heavy code or other languages. Always confirm with count_tokens before relying on a number for billing.

Pricing is per million tokens. Input and output are billed separately, and output always costs five times the input rate on every current model. Prompt caching changes only the input side: a cache write costs 1.25× the base input rate for the 5-minute cache or 2× for the 1-hour cache, while a cache read costs about 0.1× — so reused context (a fixed system prompt, a long document, few-shot examples) gets dramatically cheaper after the first call. The cost table updates live as you type, switch caching mode, or change the call count, multiplying input cost by your selected cache factor and adding the output cost on top.

Pricing reflects published Claude API rates (Opus 4.8 $5/$25, Sonnet 4.6 $3/$15, Haiku 4.5 $1/$5 per 1M tokens). Verify current rates before billing.