Tokens Calculator

Token Cost Calculator

Turn a local token count into a clear per-call API cost estimate for GPT, Claude, and Gemini model references.

o200k_base
0 / 1,000,000 characters

Token visualization

Local token pieces update 0.5 seconds after you stop typing.

0 tokens

Paste text above to see how the selected local encoder splits it into tokens.

Local calculation. Your text stays in this browser. Nothing is uploaded or stored by Tokens Calculator.

Compare input cost by configured model

Compare the same text using the available local encodings and current list-price estimates.

Edit text
ModelTokensInput / 1MInput cost
GPT-4oOpenAI0$2.50$0.000000
GPT-4OpenAI0$30.00$0.000000
Claude 3.5 SonnetAnthropic0$3.00$0.000000
Claude Sonnet 4.6Anthropic0$3.00$0.000000
Gemini 2.5 FlashGoogle0$0.30$0.000000
Gemini 2.5 ProGoogle0$1.25$0.000000

Claude and Gemini counts are useful approximations using cl100k_base; provider tokenizers can differ by model version and text.

Simple per-call math

The tool applies the listed per-million-token rate to the exact local count, so the calculation is easy to inspect.

One text, multiple references

See how a single text sample changes across the available GPT, Claude, and Gemini configurations.

No budget data leaves the page

Text is counted in your browser only, which keeps internal prompts and drafts out of a server-side log.

Configured API price reference

The calculator reads these standard USD list-price references from a single local configuration file. Provider policies, caching, tools, taxes, and special request modes can change the final bill.

ModelInput / 1MOutput / 1MCounting note
GPT-4oOpenAI$2.50$10.00Uses the o200k_base encoding.
GPT-4OpenAI$30.00$60.00Uses the cl100k_base encoding.
Claude 3.5 SonnetAnthropic$3.00$15.00Legacy model; cl100k_base approximation.
Claude Sonnet 4.6Anthropic$3.00$15.00cl100k_base approximation.
Gemini 2.5 FlashGoogle$0.30$2.50cl100k_base approximation for text.
Gemini 2.5 ProGoogle$1.25$10.00Uses standard pricing for prompts up to 200K; cl100k_base approximation.

How it works

  1. 01

    Count a representative text sample

    Paste a prompt or response that represents the text you expect to send or receive.

  2. 02

    Choose the API model

    Pick the provider model whose list price you want to reference.

  3. 03

    Choose input or output cost

    Use the mode switch to estimate the correct side of the API interaction.

Token Cost Calculator FAQ

How does the token cost calculator work?

It counts your pasted text with the selected local encoding, divides that count by one million, and multiplies it by the selected model’s configured input or output rate.

Why are input and output estimates separate?

Most providers bill prompt tokens and generated tokens at different rates. Separating them avoids pretending a single pasted string represents both sides of a future API call.

What is not included in the estimate?

The calculator does not add tokens from API message wrappers, system prompts, tool schemas, cached content, images, audio, discounts, taxes, or provider-specific service fees.

Where can I change the configured rates?

All rate references live in src/lib/pricing.ts. That central file keeps model names, encodings, price tiers, and official provider links together.

Not affiliated with Anthropic, OpenAI or Google.