Toolivaro

Free AI Token Counter

Estimate tokens and API cost for any prompt across GPT-4o, Claude Sonnet 4, and other models — fully local.

The AI token counter estimates how many tokens a prompt will consume for OpenAI and Anthropic models and converts that into an API cost estimate. Paste a prompt, system message, or code block, choose a model family, and the tool returns an estimated input token count, a context-window check, and — when you provide an expected output length — a combined input-plus-output cost. The estimate uses the vendors’ own documented heuristic of roughly one token per four characters of English text; it is an approximation, not the model’s exact tokenizer, and it is deliberately weakest for non-English text, heavy punctuation, and code. Prices are the public list rates recorded on 2026-08-05 and are shown with their as-of date so a change at the vendor never silently misleads you. Everything runs locally: the prompt you paste never leaves your device, which matters when the text contains proprietary code or sensitive data. Use this tool before a batch job to sanity-check spend, when comparing model families for a task, or when a context-window error tells you a prompt is too large to count by hand.

Processed locally in your browser

Optional — used to estimate output-token cost.

How to use this calculator

What a token is, and why the count is an estimate

A token is the unit a language model reads and writes: roughly a word, a sub-word, or a punctuation mark, depending on the model’s vocabulary. Models are billed per token, and their context windows are measured in tokens, which is why the number matters before you send a prompt. The tool estimates the count with the vendors’ own documented heuristic — about one token per four characters of English text — rather than each model’s exact tokenizer, whose BPE vocabulary is far too large to ship in a static page.

The estimate is calibrated for English prose. Non-English text, dense punctuation, code with long identifiers, and tables all tokenize differently, and the page says so plainly: for billing-critical counts the vendor tokenizer is authoritative, and this tool is for planning — sanity-checking spend before a batch job, comparing model families, or finding out why a prompt overflowed its context window.

Estimating cost before you commit

Cost is two numbers, not one: input tokens and output tokens, and they are billed at different rates — output almost always costs more per token. The tool asks for an expected output length when you want the full picture, estimates output tokens at roughly 0.75 words per token, and combines both sides at the model’s public list prices.

The prices are shown with the date they were recorded (2026-08-05) because model pricing changes — a rate update at the vendor is never silently baked into an estimate. When you are planning a real workload, confirm the current rates on the vendor’s pricing page; the tool’s job is the arithmetic, not the price forecast.

Choosing a model family for the job

The counter lets you compare models side by side: the same prompt can be 250 tokens on one family and 220 on another, and the input cost per million tokens differs enough that the comparison changes real decisions about batch size and routing. Run the same prompt across the families you are considering and read the combined cost — that is the number that belongs in a budget review, not the token count alone.

The context-window check is the other side of the comparison: a prompt that fits comfortably in one family’s window may not fit a smaller-window model at all, and the tool flags that before you discover it in an API error.

The local promise

Prompts you paste here often contain proprietary code, unpublished plans, or personal data — exactly the text you should not send to a third-party tokenizer. Everything runs in your browser: the estimate is computed locally, nothing is uploaded, logged, or stored, and there is no server that could see the text. The trade is the one disclosed above: the count is the documented heuristic rather than the exact vocabulary, which is the honest price of keeping the prompt on your device.

How is the result calculated?

A 200-word system prompt on GPT-4o

A system prompt of 1,000 characters is estimated at 250 tokens on GPT-4o (4 characters per token). At $2.50 per million input tokens the input costs about $0.0006; adding a requested 200-word answer (≈ 267 output tokens at $10 per million) brings the total to about $0.0033 per call.

Example input and output
Input Value
prompt 1,000-character system prompt
model GPT-4o
outputWords 200
Result ≈ 250 input tokens · ≈ 267 output tokens · ≈ $0.0033 per call

What is the formula and its assumptions?

Token estimate

tokens ≈ ceil(characters ÷ 4)

Formula terms
Symbol Meaning
characters length of the prompt text (code points)
4 vendor-documented approximation: ~4 characters per token (English)

An estimate, not the exact tokenizer output. Exact counts require each model’s BPE vocabulary, which cannot ship in a static page.

Cost estimate

cost = (inputTokens ÷ 1,000,000 × inputPrice) + (outputTokens ÷ 1,000,000 × outputPrice)

Formula terms
Symbol Meaning
inputPrice list price per million input tokens (as of 2026-08-05)
outputPrice list price per million output tokens (as of 2026-08-05)

Output tokens are estimated at ~0.75 words per token when you provide an expected output length.

What are the most common mistakes?

  • Treating the estimate as the exact billing count — vendor tokenizers are authoritative for billing.
  • Assuming four characters per token for non-English text — the heuristic is calibrated for English.
  • Forgetting that output tokens usually cost more per token than input tokens.
  • Pasting sensitive proprietary code into an online tokenizer — this tool keeps everything local.

What are the assumptions and limitations?

  • The estimate is heuristic (characters ÷ 4), not the model’s exact tokenizer output; accuracy drops for non-English text, dense punctuation, and code.
  • Prices are public list rates as of 2026-08-05 and may change; always confirm at the vendor pricing page before committing spend.
  • Context windows and prices apply to the listed model names at the recorded date; a model update may change both.

Where do the numbers come from?

Last reviewed August 5, 2026 · Version 1.0.0 · Toolivaro does not guarantee external content.

Frequently asked questions

Why is the count an estimate instead of exact?

Exact token counts come from each model’s tokenizer, a BPE vocabulary that ships inside the model provider’s libraries — too large to embed in a static page. The documented ~4 characters-per-token heuristic is within a few percent for typical English prompts, which is accurate enough for cost and context planning.

Does the count match the OpenAI or Anthropic tokenizer pages?

Close, but not identical. The official tokenizers use the real vocabulary and are exact; this tool uses the documented heuristic so it can run entirely in your browser. For billing-critical counts, use the vendor tokenizer — the estimate here is for planning.

Why are prices dated?

Model pricing changes. The tool records the public list rates it was built against (2026-08-05) and shows that date with every result, so a later price change at the vendor is never silently baked into an estimate.

Does the tool count output tokens for me?

Only when you provide an expected output length. Output tokens are estimated at roughly 0.75 words per token and combined with input cost at the model’s output rate. Without a length, the tool reports input cost alone.

Why is my code tokenized so differently from my prose?

Tokenizer vocabularies are trained on the language they see most: prose-heavy text tokenizes near the four-characters-per-token average, while code and non-English text drift from it. That is the main reason the estimate is an approximation rather than an exact count.

Part of Developer text and JSON toolkit

Found a mistake or have a correction? Report it — we review every correction.

Was this helpful?

Reviewed by the Toolivaro editorial team per our methodology Methodology · Editorial policy