Skip to content
100% local

LLM token and cost calculator

Estimate how many tokens a pasted text costs across popular LLM APIs.

Input
Output

LLM token and cost calculator

Paste a prompt, document or chat transcript and this tool estimates how many tokens it would consume, then converts that into an approximate dollar cost across a handful of popular models — GPT-4o, GPT-4o mini, Claude Sonnet, Claude Haiku and Claude Opus. It's built for quick sanity checks before sending a large batch of requests through an API, not as a substitute for the exact usage numbers a provider's dashboard reports afterward.

Token counting here is a heuristic, not an exact count. Real tokenizers use byte-pair encoding trained on huge corpora, and reproducing one client-side would mean shipping megabytes of merge tables for one feature. Instead, this tool applies the rule of thumb most API docs quote — roughly four characters or three-quarters of a word per token for English and other Latin-script languages — and switches to a denser ratio for CJK text (Chinese, Japanese, Korean), where a character commonly maps to close to one token instead of a quarter. Mixed text is classified character by character, so a paragraph switching between English and Japanese gets a blended estimate.

Reference prices are hardcoded at what each provider listed when this tool was built, shown per million tokens. Toggle "Price as output tokens" to price the same count at each model's output rate instead — output is consistently priced higher than input, which matters when estimating a completion rather than a prompt. The table updates as you type, so trimming a prompt shows its effect across every model at once.

Everything runs locally: the text you paste is never uploaded anywhere, so it's safe to use on a prompt containing confidential material. Because the token count is an estimate, treat the numbers as a planning aid — for exact billing, check the usage your API provider actually reports.

FAQ

How accurate is the token estimate?
It is a heuristic, typically within about 10-20% of the real count for ordinary prose. Real BPE tokenizers can only be reproduced exactly by shipping the provider's own vocabulary, which this tool intentionally avoids to stay a lightweight, client-side estimate.
Why does the same text estimate differently for CJK languages?
Chinese, Japanese and Korean text tokenizes far more densely than Latin-script text — often close to one token per character rather than one token per four characters. The tool detects these scripts and applies a separate ratio so the estimate stays reasonable for mixed-language text too.
Are the prices live?
No. They are hardcoded reference prices set when this tool was built, not fetched from any API. Providers change pricing periodically, so check the model provider's current pricing page before making a budgeting decision.
What does "Price as output tokens" change?
It switches every model to its output-token rate instead of its input-token rate. Output tokens are billed at a higher rate than input tokens for every model in the table, so this toggle is useful when you are estimating the cost of a generated response rather than a prompt you are sending.
Is my text uploaded anywhere?
No. The token estimate and cost calculation run entirely in your browser — nothing you paste here is sent to OpenAI, Anthropic or any other service.