AI Token Counter
Paste text to count tokens. The OpenAI count is exact: it runs OpenAI's own o200k_base tokenizer in your browser. Claude, Gemini, Mistral and Llama use other tokenizers, so for them you get a clearly labelled estimate and the official way to get the exact number.
Your text never leaves your browser — nothing is sent to a server.
Your Text
Token Count by Model
What is a token?
Language models don't read characters or words. A tokenizer first splits text into tokens — frequent words become one token, rarer words are split into pieces, and punctuation, digits and spaces get tokens of their own. Prices, rate limits and context windows are all measured in tokens.
A few words run through OpenAI's o200k_base tokenizer (counted with the same code this page uses):
- "Hello" → 1 token
- "calculator" → 1 token
- "tokenization" → 2 tokens
- "ChatGPT" → 2 tokens
- "1000" → 2 tokens
Every model family has its own tokenizer
| Family | Tokenizer | On this page | Exact count |
|---|---|---|---|
| OpenAI GPT-4o, GPT-4.1, GPT-5, o-series | o200k_base (tiktoken BPE) | Exact | tiktoken library |
| OpenAI GPT-4, GPT-3.5 Turbo | cl100k_base (tiktoken BPE) | Close estimate | tiktoken library |
| Anthropic Claude | Anthropic's own; not published. Claude Opus 4.7 and later use a newer tokenizer that yields about 30% more tokens than earlier Claude models | Ballpark | count_tokens API (free) |
| Google Gemini | Google's own; about 4 characters per token by Google's rule of thumb | Estimate (characters ÷ 4) | countTokens API |
| Mistral | Tekken (based on tiktoken) or SentencePiece in older versions | Ballpark | mistral-common library |
| Meta Llama 3 | 128K-token vocabulary | Ballpark | tokenizer shipped with the model weights |
Model-to-encoding mapping for OpenAI follows tiktoken's own model table. Newer OpenAI models not yet in that table are assumed to use o200k_base.
Rules of thumb — and where they break
OpenAI's tiktoken documentation says a token is "about 4 bytes" on average; Google says a Gemini token is "about 4 characters" and that 100 tokens are "about 60–80 English words". Those averages hold for typical English prose. They drift as soon as the text changes. We measured one sentence with the same meaning in three languages, plus a line of code, using o200k_base:
| Sample | Characters | Tokens | Characters per token | Tokens per word |
|---|---|---|---|---|
| English sentence | 121 | 18 | 6.7 | 1.1 |
| Same sentence in German | 126 | 24 | 5.3 | 1.7 |
| Same sentence in Polish | 121 | 35 | 3.5 | 2.1 |
| One line of JavaScript | 87 | 28 | 3.1 | — |
The Polish sentence has the same length in characters as the English one but needs almost twice as many tokens, so it costs almost twice as much to process. One sentence is not a benchmark — paste your own text above to see your real ratio — but the direction is typical: languages with long, inflected words and code full of symbols use more tokens per character than plain English.
How to get the exact count from each vendor
- OpenAI: the open-source
tiktokenlibrary —tiktoken.encoding_for_model("gpt-4o")returns the right encoding, andlen(enc.encode(text))is the count. This page uses the JavaScript port of the same tokenizer. - Anthropic Claude: the
POST /v1/messages/count_tokensendpoint accepts the same input as a real request (system prompt, tools, images, PDFs) and returnsinput_tokens. It is free but rate-limited, and Anthropic calls the result an estimate that can differ slightly from billing. Count against the exact model you will use — the tokenizer changed with Claude Opus 4.7. - Google Gemini: the
countTokensmethod returns the input token count before you send a request. Images, audio and video have their own rates — for example, Google lists audio at 32 tokens per second. - Mistral: the
mistral-commonlibrary implements Mistral's tokenizers, including the tiktoken-based Tekken. - Llama: use the tokenizer distributed with the model weights you run.
Frequently asked questions
Is this token counter exact?
For OpenAI models that use the o200k_base encoding (GPT-4o, GPT-4.1, GPT-5 and the o-series), yes: the page runs the same tokenizer in your browser. For Claude, Gemini, Mistral and Llama it shows an estimate, because those vendors do not ship a browser tokenizer for their current models. Use their official tools for an exact number.
How many tokens is 1,000 words?
For typical English prose roughly 1,300–1,700 tokens: Google puts 100 tokens at about 60–80 English words. Other languages and code need more — in our measured example the same sentence took about 1.1 tokens per word in English and 2.1 in Polish. Paste your own text above for a real count.
Why do Claude, Gemini and GPT give different counts for the same text?
Each family uses its own vocabulary. OpenAI uses tiktoken encodings, Mistral uses Tekken (based on tiktoken) or SentencePiece, Llama 3 has a 128K-token vocabulary, and Anthropic and Google use their own tokenizers. Anthropic notes that Claude Opus 4.7 and later produce about 30% more tokens for the same text than earlier Claude models.
How do I count Claude tokens exactly?
Call Anthropic's free count_tokens endpoint (POST /v1/messages/count_tokens) with the same model, system prompt, messages and tools you plan to send. It returns input_tokens. It is rate-limited and Anthropic describes the result as an estimate that can differ slightly from billing.
Does code use more tokens than English text?
Usually yes per character. Our one-line JavaScript example came to about 3.1 characters per token, against 6.7 for an English sentence, because brackets, operators and identifiers split into many small tokens. Comments written in English tokenize like prose.
How do I reduce token usage?
Shorten system prompts, remove repeated instructions, summarise long conversation history instead of resending it, use compact JSON keys for structured data, and use prompt caching where the provider supports it for repeated context.
Sources (checked October 2026)
OpenAI tiktoken — github.com/openai/tiktoken (encodings, model table, "about 4 bytes" per token)
Anthropic token counting — platform.claude.com/docs/en/build-with-claude/token-counting
Google Gemini tokens — ai.google.dev/gemini-api/docs/tokens
Mistral tokenization — docs.mistral.ai/guides/tokenization and github.com/mistralai/mistral-common
Meta Llama 3 announcement — ai.meta.com/blog/meta-llama-3 (128K-token vocabulary)