LLM Token Counter

Know how many tokens your prompt really uses and what it will cost before you send it. Tokens are not words and not characters, so the rules of thumb — four characters per token, three-quarters of a word — are wrong often enough to blow a context window or a budget. This counter runs the model's actual vocabulary in your browser, so the number you see is the split the model itself performs and the number the API bills you for. Because families tokenize differently, picking a model swaps the tokenizer rather than just the price: the same paragraph can differ by twenty percent between GPT-4o and Llama. Counts for GPT-4o, GPT-4, Llama 3, Gemma, Mistral and Qwen are exact. Anthropic publishes no tokenizer, so Claude is shown as a clearly-labelled estimate rather than dressed up as precise. You also get the token-by-token breakdown, context-window use, and a cost estimate with prices you can edit as vendors change them. Your prompt is tokenized in the page — it is never uploaded, and no model is called.

Tokenizer accuracy by model

ModelTokenizerAccuracy
GPT-4oo200k_baseExact
GPT-4 / GPT-3.5cl100k_baseExact
Llama 3.xLlama 3Exact
Gemma / GeminiGemmaExact
Mistral / MixtralMistral v3Exact
Qwen 2.5Qwen 2.5Exact
ClaudeGPT-4o stand-inEstimate — no tokenizer published

When to use it

  1. Check a prompt fits a model's context window before you send it.
  2. Estimate what a batch of API calls will cost.
  3. Compare how the same text tokenizes across model families.
  4. Work out why a prompt is more expensive than you expected.
  5. Size a chunk for a retrieval pipeline against a real tokenizer.

How to Use

  1. Paste or type your text.
  2. Pick the model you are targeting — this changes the tokenizer, not just the price.
  3. Read the token count, context-window use and cost estimate.
  4. Edit the prices to match your current rates if they have changed.

Features

  1. Real tokenizers, not character ratios
  2. Exact counts for GPT-4o, GPT-4, Llama 3, Gemma, Mistral and Qwen
  3. Claude shown as a clearly-labelled estimate, not false precision
  4. Token-by-token breakdown with whitespace made visible
  5. Context-window usage with an over-limit warning
  6. Cost estimate with editable input and output prices
  7. Sub-cent costs shown instead of rounding to $0.00
  8. Grapheme-aware character counts and CJK-aware word counts
  9. 100% client-side — prompts are never uploaded

FAQs

Is my prompt uploaded?

No. The tokenizer vocabulary is downloaded once and cached, then all counting happens in your browser. No model is called and your text is never transmitted — which matters, since prompts routinely carry proprietary instructions and customer data.

Are the counts exact?

For GPT-4o, GPT-4, Llama 3, Gemma, Mistral and Qwen, yes — the tool runs each model's own published vocabulary, so the split matches what the API sees. Claude is an estimate: Anthropic does not publish its tokenizer, so no offline tool can count Claude tokens exactly, and the tool says so rather than implying otherwise.

Why not just divide characters by four?

Because tokenization is not proportional to length. Code, JSON, non-English text, rare words and emoji all tokenize far more densely than ordinary English prose — a JSON blob can run two or three times the tokens the rule of thumb predicts. That gap is exactly where context windows overflow unexpectedly.

Why does the count change when I switch models?

Each family has its own vocabulary, trained on different data. The same paragraph commonly differs by ten to twenty percent between GPT-4o and Llama, and more for non-English text. Switching the model here switches the tokenizer, not just the price.

Are the prices current?

They are defaults and vendors change them regularly, so treat them as a starting point and edit them. Your edits are remembered on this device. Always confirm against the vendor's own pricing page before relying on an estimate.

Why does the first count take a moment?

The tokenizer vocabulary has to be fetched the first time you use a given model — a few megabytes. Your browser caches it, so subsequent counts with that model are instant and work offline.

Technical Details

Tokens are not words and they are not characters, so any counter that multiplies by a ratio is guessing. This one runs the model's actual byte-pair-encoding vocabulary through Transformers.js: the tokenizer definition is fetched once, cached by the browser, and every count after that is the same split the model itself would perform — which is why a count here matches what the API bills you for rather than approximating it. Different families tokenize the same text differently, sometimes by twenty percent or more, so the model selector changes the vocabulary rather than just a price. GPT-4o and GPT-4 use OpenAI's o200k and cl100k vocabularies, and Llama, Gemma, Mistral and Qwen each use their own published tokenizer; those counts are exact. Anthropic does not publish a tokenizer at all, so no offline tool can count Claude tokens exactly — Claude is labelled an estimate and uses the GPT-4o vocabulary as a documented stand-in, rather than being presented with a precision it does not have. Cost is computed per million tokens with editable input and output prices, formatted to enough decimal places that a prompt costing a fraction of a cent does not round away to zero. Context-window use is shown against the selected model's real window. Characters are counted by grapheme through Intl.Segmenter, so a multi-code-point emoji counts as one character, and words are counted with CJK handled per character, since Chinese and Japanese are not space-separated. The text is tokenized entirely in the page: prompts, which routinely contain proprietary instructions and customer data, are never sent anywhere and no model is ever called.

Developer Tools

Developer Tools

  • .gitignore Generator
  • Dummy Data Generator
  • RAID Calculator
  • Download Time Calculator
  • JSON Formatter
  • JSON Validator
  • Base64 Encoder / Decoder
  • URL Encoder / Decoder