AT AI Tools

AI Token Counter

Count tokens for GPT-5, GPT-4o, Llama, Qwen, DeepSeek, Mistral, Gemma, Gemini and Claude using real tokenizers that run privately in your browser.

πŸ”’ Runs entirely in your browser β€” nothing is uploaded

The tokenizer (a few MB) is downloaded once from Hugging Face and cached. Your text never leaves this device.

Tokens0
Characters0
Words0
Chars / token–
Was this tool useful? Rate it:

What a token is and why it matters

Large language models do not read characters or words. They read tokens: pieces of text from a fixed vocabulary, often a whole short word, part of a longer word, a space plus a word, or a single punctuation mark. API prices, rate limits and context windows are all measured in tokens, so knowing the token count of a prompt tells you what it will cost, whether it fits in the model's context and how much room is left for the answer. As a rule of thumb, one token is about four characters of English text, but the real number depends on the language, the content and the model.

This counter uses the real tokenizers published by OpenAI, Meta, Alibaba (Qwen), DeepSeek, Mistral and Google (Gemma). For those models the count is exact. Tokenization runs locally with transformers.js, so confidential prompts, source code and documents stay on your device.

Exact counts and estimates

OpenAI's o200k_base encoding is used by GPT-5, GPT-4.1, GPT-4o and the o-series models, while the older cl100k_base covers GPT-4, GPT-3.5 Turbo and the text-embedding-3 models. Open-weight models ship their tokenizer with the model, so those counts are exact too. Anthropic and Google do not publish the tokenizers of current Claude and Gemini models. For them the tool uses the closest public tokenizer and marks the number as an estimate, which is good for budgeting but can be off by several percent.

Always the latest tokenizer

Tokenizers are not bundled into this page. When you pick a model, the tool checks Hugging Face for the most recent version of that tokenizer and downloads it only if it changed, so fixes published upstream are used automatically. The repository and version are shown below the text box. Tips for saving tokens: remove repeated boilerplate, prefer plain text over heavy markup, and keep in mind that non-Latin scripts and emoji usually need more tokens per character.

How to use

  1. Pick a modelChoose the model family you are writing for, such as GPT-4o, Llama 3, Qwen or Claude.
  2. Paste your textPaste a prompt, document or code. The count updates as you type.
  3. Read the countsSee tokens, characters, words and characters per token, and check whether the count is exact or an estimate.
  4. Inspect the tokensTurn on Show tokens to see exactly how the text is split, which helps you trim long prompts.

Frequently asked questions

Is my text uploaded?
No. Only the tokenizer files are downloaded from Hugging Face. Tokenization runs in your browser and your text never leaves your device.
Why do different models give different counts?
Each model family has its own vocabulary. The same sentence can be 20 tokens for one model and 26 for another, especially for non-English text, code and emoji.
Are the Claude and Gemini counts exact?
No. Anthropic and Google have not published the tokenizers used by current Claude and Gemini models, so the tool uses the closest public tokenizer and labels the result as an estimate. Use the vendor's count-tokens API when you need an exact number.
How does the tool stay up to date?
Every time a tokenizer is loaded, the tool asks Hugging Face for the latest version of its repository. If it changed, the new files are downloaded; otherwise the cached copy is used. The version is shown under the text box.
Do the counts include chat formatting?
No. The count covers your text only. Chat APIs add a few extra tokens per message for role markers and templates.