AI Token Counter & Cost Calculator — Claude, OpenAI, Gemini | AI Error Hub
AI Error Hub/ Tools/ Token Counter
Free tool · Runs in your browser

AI Token Counter & Cost Calculator

Paste any text to estimate token count and cost across every major AI provider — Claude, OpenAI, Gemini, Bedrock, and Azure. Includes prompt caching, output ratio, and monthly cost projection.

Nothing you paste leaves your browser. All calculations run locally on this page.

Input
0 characters
Result — Selected model
Input tokens
0
Est. output tokens
0
Cost per request
Input tokens$0.00
Output tokens$0.00
Total per request$0.00
Projected monthly cost
$0.00
0 requests/month
Compare all providers · sorted by monthly cost

How this works

This tool estimates token counts using character-per-token ratios that approximate each provider's real tokenizer for English-language text. Cost figures use the September 2026 published rates for each provider.

Estimation accuracy

The character-based approach is accurate to within roughly 5-10% for English prose. It's less accurate for:

  • Code: tends to tokenize more densely than prose — real token counts run about 15-20% higher than these estimates
  • Non-English text: especially languages that don't use spaces (Chinese, Japanese, Thai) where token counts can be 2-3× higher than the character-ratio suggests
  • Structured data (JSON, XML): whitespace and repeated tokens compress better than the estimate suggests

For exact counts, use each provider's official tokenizer library: tiktoken (OpenAI), anthropic.tokenize() (Claude), Google's Gemini SDK count_tokens. For quick cost estimation and provider comparison, this tool is more than accurate enough.

What "cache write" means

When prompt caching is enabled, tokens that aren't already cached must be written to the cache — this costs slightly more than a regular input token (1.25× on Anthropic, no premium on OpenAI, no premium on Gemini). The tool splits input tokens into cache reads (the cache hit rate portion) and cache writes (the miss portion) automatically.

Cache write cost is real but usually recovered after the first cache hit. For deeper coverage see the Prompt Caching Setup Guide.

Monthly cost projection

The monthly figure is simple: cost per request × requests per day × 30. It's a linear projection — real usage patterns (spiky vs uniform, weekend variance, seasonal effects) will shift the actual bill. Use it for sizing decisions, not for financial forecasting.

Pricing data

All prices reflect the published September 2026 rates for direct provider access. Enterprise contracts, committed-use discounts, and marketplace pricing may vary. Verify current pricing on each vendor's site before making commitments.