AI Token Counter

Estimate tokens and cost for any LLM prompt across GPT-4o, Claude 3.5, Gemini 1.5, Llama 3 and more. See per-model token count, input cost, projected output cost and context window utilization — all in real time, runs entirely in your browser. No API key, no signup.

Active model:
Estimated tokens (GPT-4o)
0
Input cost: $0.00 + Output cost: $0.00 = Total: $0.00
Context window: 0 / 128,000 tokens (0%)
0
Words
0
Characters
0
Chars (no spaces)
0
Lines

Per-model token count & cost

Model Tokens Input cost Total cost Context use

What Is a Token and Why Does It Matter?

In large language models like GPT-4, Claude or Gemini, a token is the smallest unit of text that the model actually processes. It can be a whole word, part of a word, a single character, or a punctuation mark — depending on the model's tokenizer. Tokens matter because every interaction with an LLM is priced and bounded by tokens: you pay per million tokens (input + output), and the model can only "see" a finite number at a time, called the context window.

Counting tokens accurately is essential when you're building anything on top of LLMs: a RAG pipeline that retrieves and stuffs documents into a prompt, a customer-support bot that needs to estimate cost per conversation, a long-form article generator that must stay within a context limit, or a developer just trying to keep API bills sane. This AI token counter gives you instant per-model estimates across 10+ leading LLMs, plus cost projections and context-window utilization, all without needing an API key or sending your text anywhere.

How LLM Tokenization Works

Modern LLMs use a technique called Byte-Pair Encoding (BPE), or one of its descendants like SentencePiece. The tokenizer learns a fixed vocabulary of subword pieces during pretraining — usually 50,000 to 200,000 entries. When you submit text, it's broken down greedily into the longest known pieces. A common English word like "hello" is one token; an uncommon name like "Gandalf" might be two or three; a code symbol like { is often its own token.

Different models use different tokenizers, which means the same text can have different token counts depending on which model you're targeting. GPT-4 and GPT-4o share the cl100k_base tokenizer with ~100K vocab entries. Claude uses Anthropic's proprietary tokenizer (similar size, slightly different splits). Gemini uses Google's SentencePiece variant. Llama 3 uses its own 128K-entry tokenizer. As a rough rule, English text averages ~4 characters per token across all these models, with code being denser (~3 chars/token) and non-Latin scripts much denser still.

How to Use This Token Counter

Step 1 — Paste your text. Drop any prompt, document, code snippet or article into the textarea. The counter updates live as you type or paste.

Step 2 — Pick the active model. Choose from GPT-4o, GPT-4o-mini, GPT-4 Turbo, GPT-3.5, Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku, Gemini 1.5 Pro, Gemini 1.5 Flash, or Llama 3.1 70B. The hero number shows the estimated token count for that model.

Step 3 — Set expected output tokens. Default is 500. Adjust to your typical response length to get accurate total-cost projections.

Step 4 — Read the per-model table. See the same prompt costed across every model side-by-side. Use it to pick the most cost-effective model for your use case — Claude 3 Haiku and Gemini 1.5 Flash are often dramatically cheaper than Claude Opus or GPT-4 Turbo for the same input.

LLM Cost Optimization Tips

If your AI bill is high, the biggest savings usually come from these levers:

Why This Counter Uses Estimation Instead of Exact BPE

An exact tokenizer requires the model's vocabulary file: ~500 KB to 2 MB of merge rules per tokenizer. Loading 10 different tokenizers (one per model family) would inflate this page to 10+ MB, which would be terrible for performance and counter to the "instant, in-browser" promise of this tool. Instead, the counter uses a calibrated hybrid heuristic that blends character counts and word counts with per-model multipliers tuned against the real BPE tokenizers on natural English text. The result is typically within 5–10% of exact, which is plenty accurate for cost estimation, context planning and "will this fit?" decisions. For code-heavy or non-English text the drift can be larger, but the estimate is still a useful order-of-magnitude check.

Token Count Examples

Short instruction (~70 chars)
Summarize the following article in three bullet points, then suggest a title.

GPT-4o: ~18 tokens · Claude 3.5: ~20 tokens · Gemini 1.5: ~18 tokens
Medium article chunk (~1000 chars)
~250 tokens across most models.
Cost on GPT-4o at $2.50/1M input: ~$0.0006 per request.
Cost on Claude Haiku at $0.25/1M input: ~$0.00006 per request (10× cheaper).
Code snippet (Python, ~500 chars)
Code is denser than prose: expect ~3 chars per token instead of ~4.
A 500-char snippet typically lands at ~170 tokens.
Indentation, brackets and operators each consume their own token slots.

Frequently Asked Questions

A token is the smallest piece of text an LLM processes. It can be a whole word, part of a word, or a single punctuation mark, depending on the model's tokenizer. As a rough rule, 1 token ≈ 4 characters or ≈ 0.75 words for English text in GPT-style models.

Typically within 5–10% of the actual BPE tokenizer for natural English text. The counter uses a calibrated hybrid of character and word counts with per-model multipliers tuned against real tokenizers. For code-heavy or non-English text, drift can be larger but the result is still a useful order-of-magnitude estimate for cost and context planning.

They use different tokenizers. GPT-4 and GPT-4o use OpenAI's cl100k_base BPE tokenizer; Claude uses Anthropic's proprietary tokenizer with a similar vocabulary size but different merge rules. For the same English text, Claude typically counts slightly more tokens than GPT (about 5–10% more), because its tokenizer breaks some words into smaller subwords.

BPE tokenizers learn a vocabulary during pretraining. Common words ("the", "and", "hello") are usually single tokens. Rare words, proper names, technical jargon, or words with unusual capitalization are split into multiple subword pieces. For example, "tokenization" might be split as "token" + "ization" — two tokens instead of one.

The biggest savings: (1) pick a cheaper model — GPT-4o-mini or Claude Haiku are often 10–60× cheaper than GPT-4 Turbo or Claude Opus for similar quality on routine tasks. (2) Shorten your system prompt — every request resends it. (3) Use prompt caching for repeated prefixes (now supported by OpenAI, Anthropic and Google). (4) Ask for concise outputs — output tokens cost 3–5× more than input.

The context window is the maximum number of tokens the model can process in a single request (input + output combined). GPT-4o has a 128K-token window; Claude 3.5 Sonnet has 200K; Gemini 1.5 Pro has 2M. If your prompt exceeds the window, the model can't process it. This counter shows the utilization bar so you can see how close you are to the limit.

Input tokens are what you send to the model (your prompt, system instructions, conversation history). Output tokens are what the model generates back. Output tokens are typically 3–5× more expensive than input. The total cost of a request is input_tokens × input_price + output_tokens × output_price.

Everything runs in your browser. Your text, the token estimation, the cost calculation — none of it is sent to any server. No signup, no API key, no tracking of prompt content. Your draft is optionally saved to localStorage so you can come back to it, but never transmitted.