tool / ai

Token Counter

Paste any text to instantly count tokens and estimate API costs across GPT-4o, Claude 3.5, Gemini, and more. Uses a cl100k_base approximation — no API calls, no data leaves your browser.

← Back to tools
Paste or type text
~0tokens
0characters
0words
0lines

Estimated API cost

Based on ~0 input tokens and ~0 output tokens. Prices from public provider pages (may vary).

ModelProviderInput costOutput costTotal
GPT-4oOpenAI$0.0000$0.0000$0.0000
GPT-4o miniOpenAI$0.0000$0.0000$0.0000
Claude 3.5 SonnetAnthropic$0.0000$0.0000$0.0000
Claude 3 HaikuAnthropic$0.0000$0.0000$0.0000
Gemini 1.5 ProGoogle$0.0000$0.0000$0.0000
Gemini 2.0 FlashGoogle$0.0000$0.0000$0.0000
Pricing per 1M tokens — Input / Output:GPT-4o: $5 / $15GPT-4o mini: $0.15 / $0.6Claude 3.5 Sonnet: $3 / $15Claude 3 Haiku: $0.25 / $1.25Gemini 1.5 Pro: $3.5 / $10.5Gemini 2.0 Flash: $0.075 / $0.3

What are tokens?

Language models don't read text character by character — they process tokens, which are chunks of text roughly 4 characters long for English. A word like "hello" is 1 token; "unbelievable" might be 3–4 tokens.

Why does it matter?

LLM APIs charge per token — for both input (your prompt + context) and output (the response). Knowing your token count helps you optimize prompts, choose the right model, and predict costs before running large batches.

Approximation accuracy

This tool uses a regex-based approximation of cl100k_base encoding. Results are typically within 5–10% of the actual count. For exact counts, use the official tiktoken library or the provider's tokenizer API.

How to Use It

Paste text into the box — or use the upload button to load a file — and the counts update as you type: tokens, characters, words, and lines. Below that, the cost table estimates what the text would cost as an API call across the listed models. The assumed output ratio selector is worth understanding: it models how long the response will be relative to your input. A yes/no classifier is close to 1×; asking a model to expand bullet points into prose is more like 5–10×. Since output tokens usually cost several times more than input, that ratio moves the estimate more than anything else on the page.

When You'd Actually Use This

Before a batch run. Paste one representative document, multiply by your document count, and know the bill before you write the loop.

Trimming a system prompt. That prompt gets sent with every single request, so every token you cut is cut thousands of times. Paste it, see the real count, and find out whether your "brief" instructions are quietly costing 800 tokens per call.

Fitting a context window. Wondering whether your document plus instructions fits in a model's context limit? Count first, chunk later — or don't chunk at all if you don't need to.

FAQ

Does my text get sent anywhere?

No. The counting is a local approximation that runs entirely in your browser — no API calls, no logging. Safe for contracts, medical text, or anything else you can't paste into a random website that phones home.

How accurate is the count?

Typically within 5–10% of the real tokenizer, since this uses a regex approximation of cl100k_base rather than the full encoding tables. Fine for budgeting and prompt trimming; use the provider's official tokenizer when an exact number matters.

Do all models tokenize text the same way?

No — each model family has its own tokenizer, so the same text yields somewhat different counts on GPT, Claude, and Gemini. The differences are usually small enough that one approximation works for cost planning across all of them.

How do I compare more models than the ones shown here?

Take your token counts to the LLM Cost Estimator, which pulls live pricing for hundreds of models from OpenRouter and lets you sort by total cost.

// huntermussel

Building something with LLMs and need help with cost optimization?

HunterMussel designs production AI pipelines with intelligent caching, context compression, and model routing strategies — so you ship faster and spend less on API costs.

Explore AI Automation Services →

Advertisement · Publicidade