LLM Token Counter & Cost Estimator
Count tokens locally in your browser, visualize token boundaries, and compare input, output, and prompt caching costs across leading frontier and open-weight models.
How it works
- 1Paste your prompt, source code, JSON payload, or document into the editor—nothing is sent to any server.
- 2We run exact o200k_base Byte-Pair Encoding (BPE) locally in JavaScript and apply calibrated multipliers for Anthropic, Google, DeepSeek, and Llama tokenizers.
- 3Inspect individual BPE token pills to spot inefficient formatting, long JSON keys, or whitespace overhead.
- 4Compare single-call and 10,000-call API costs, prompt cache discounts, and context window usage across major models in real time.
Frequently asked questions
Is my prompt data sent to a server when counting tokens?
No. Tokenization runs 100% client-side in your browser using the gpt-tokenizer o200k_base BPE vocabulary. Your text never leaves your device.
How accurate are token counts across non-OpenAI models?
Counts for GPT-6.2 Astra/Sol, GPT-6.1 Terra, GPT-6 Luna, and GPT-5.4 are exact o200k_base BPE counts. Counts for Claude 5.5, Gemini 4, DeepSeek V4, and Llama 4 apply calibrated multipliers to reflect each family's vocabulary density—typically within 2–5% of provider usage endpoints.
Why does the BPE Token Visualizer pause above 3,500 characters?
Rendering thousands of individual DOM pills while you type can slow down older browsers. Above 3,500 characters we keep exact token counting and pricing live while pausing chunk highlighting.
How is prompt cache savings calculated?
For models that offer discounted cached input reads (such as Claude 5.5 at 95% off, GPT-6.2 at 95% off, Gemini 4 at 95% off, or DeepSeek V4.1 Flash at 98% off), the table shows the dollar difference per 10,000 calls compared to uncached input pricing.
Related tools
View all tools →Check 1M context usage and cache savings for Claude Fable 5.2, Opus 5.5, Sonnet 5.5, and Haiku 5.5.
Exact o200k_base BPE counts for GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Terra, and GPT-6 Luna.
Model monthly API spend based on daily requests, cache hit rate, and output token ratios.
Check GPU and Apple Silicon memory requirements for 7B–671B open-weight models.
Refine rough prompts with CO-STAR or Claude XML structure to reduce wasted tokens.
Strip Markdown clutter and invisible Unicode characters before pasting or tokenizing.