CalculateTokens

About Calculate Tokens

Calculate Tokens is a browser-native token calculator that shows exact token counts and API costs across all major large language models — side by side, in real time, without your text ever leaving your device.

Why we built it

Token counting sounds simple, but it's harder to get right than it looks. Most calculators apply OpenAI's tokenizer to every model regardless of provider. That introduces significant error: roughly 65% on Gemini models and 32% on Llama 3 — because those models use entirely different tokenization schemes.

If you're estimating API costs at scale, a 30–65% counting error translates directly into a budget error of the same size. That's the problem Calculate Tokens solves.

How it works

Each model family runs its own tokenizer, compiled to WebAssembly, in a dedicated Web Worker:

Model familyTokenizer
GPT-3.5, GPT-4 familytiktoken cl100k_base
GPT-4o, o-seriestiktoken o200k_base
ClaudeAnthropic tokenizer (Wasm)
GeminiGemini tokenizer (Wasm)
Llama 3SentencePiece (Wasm)
DeepSeek, othersPer-model tokenizer or heuristic

Workers load lazily on first use. Until a tokenizer resolves, a fast character-count heuristic (Math.ceil(chars / 4)) is shown with a “~” prefix. Once the Wasm tokenizer is ready, the count updates silently — no page reload, no layout shift.

Privacy by design

Core guarantee: The text you paste into the calculator is processed entirely inside your browser. It is never transmitted to any server, never logged, and never encoded in share URLs.

Shareable URLs encode only configuration — slider values, model selection, and toggle states. The site sets no cookies and collects no personal identifiers. See the Privacy Policy for full details.

Pricing data

All pricing is sourced directly from provider pricing pages and stored in a human-reviewed prices.json file. A CI pipeline checks for page changes daily and opens an issue when a provider updates their rates.

Each model entry shows when it was last human-verified. A staleness indicator appears when prices haven't been confirmed recently. Prices may change — always verify against the provider's current pricing page before making purchasing decisions.

Open source

Calculate Tokens is released under the MIT License. The project is built with Next.js, Tailwind CSS, and deployed on Cloudflare Pages. All tokenizer Wasm builds are community-maintained open-source packages.

Get in touch

Questions, bug reports, or feature suggestions are welcome. Reach us at [email protected] or visit the Contact page.