How it works
When you paste text into the calculator, the page tokenizes it locally — in JavaScript, on your browser, using the same kind of byte-pair encoders the model vendors use. For inputs longer than 50,000 characters, the work moves to a Web Worker so the page stays responsive. The number you see is computed on your machine and multiplied by the per-million pricing the vendor publishes.
OpenAI ships a canonical client-side tokenizer (o200k_base), so GPT-5 and GPT-4.1 counts are exact. Anthropic and Google don't publish current client tokenizers, so we approximate Claude with cl100k_base and Gemini with o200k_base, applying per-model calibration to nudge the result toward the vendor counts. In practice the drift is ±2–3% on typical English and code; treat those numbers as budgeting estimates, not billing reconciliations.
What we promise
- Your prompt never leaves your browser. There is no server endpoint that ever receives prompt text. The only serverless function on this site is
/api/og— used to render social preview images — and it only accepts two short query strings used in the OG card itself. - Analytics are aggregate. We use Vercel Web Analytics for page-level metrics and Microsoft Clarity for session replay; both are configured to mask the prompt textarea and cost totals. See the privacy policy for specifics, or the verify-privacy panel on the calculator for a live tally.
- Pricing data is dated. Every model carries a
dataAsOfstamp showing when we last verified its rate against the vendor's public pricing page. See pricing data for the current table.
Built by
tokenmath is part of the Vertex Network — a small set of developer + creator tools sharing a common stack and design language. For a running list of what's shipped, see the changelog.