About Token Counter
This token counter is free, needs no sign-up and runs in your browser. Paste any text and it counts tokens with the real OpenAI tokenizers (the gpt-tokenizer library), so the count for GPT-4o, GPT-4, GPT-3.5 and older models is exact for the text you give it. The text is never uploaded.
Language models read tokens, not words. A token is a chunk of text, usually a few characters, and both the context limit and the price of a request are measured in tokens. The page shows the token count, the characters and words, and your text split into coloured tokens so you can see where the pieces fall. Switch on token ids to see the numbers the model receives.
Not every model has a tokenizer that can run here. For Claude, Gemini and Llama the page gives a clearly labelled estimate, based on a stated number of characters per token, and never presents it as an exact count. There is also a cost field where you enter your own price per million tokens, because provider prices change and are not built in.
How to use Token Counter
- Paste your prompt or text into the box, or tap a sample.
- Choose the encoding. o200k_base is for GPT-4o and newer, cl100k_base for GPT-4 and GPT-3.5 Turbo.
- Read the exact token count, characters, words and characters per token.
- Look at the coloured tokens below. Turn on Show token ids to see the numbers.
- To see an estimate for Claude, Gemini or Llama, pick the model in the estimate panel. It is labelled as an estimate.
- To work out a cost, type your price per 1 million tokens from your provider's pricing page.
Features
- Exact token counts with o200k_base, cl100k_base, p50k_base and r50k_base.
- Coloured token view, with the id of each token on hover and a switch to list all ids.
- Characters, words and characters-per-token ratio.
- Estimates for Claude, Gemini and Llama, labelled as estimates with the ratio shown.
- Cost calculator that uses the price you enter, so it never goes out of date.
- Handles other scripts and emoji, and groups tokens that split one character.
- The tokenizer loads on demand, so the page itself stays light.
How the cost is calculated
Providers price tokens per million. Enter that price and the cost is the token count divided by one million, times the price. Most providers charge a different price for input and output tokens, so run your prompt and your expected answer separately.
cost = tokens / 1,000,000 x price per 1M tokens
estimated tokens = ceil(characters / characters per token)Worked examples
hello world gives 2 tokens (all four encodings)
Two common words are one token each, the second with its leading space.
function add(a, b) { return a + b } gives 12 tokens with o200k_base and cl100k_base, 13 with p50k_base
The older encoding spends an extra token on code whitespace.
আমি ভাত খাই। gives 6 tokens with o200k_base, 15 with cl100k_base, 22 with p50k_base
The same Bangla sentence costs more than three times as many tokens with the older encodings.
Which encoding belongs to which model
| Encoding | Models |
|---|---|
| o200k_base | GPT-4o, GPT-4.1, o1, o3, o4-mini |
| cl100k_base | GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, text-embedding-3 |
| p50k_base | text-davinci-002 and 003, Codex |
| r50k_base | GPT-3 davinci, curie, babbage and ada; GPT-2 is close |
Good to know
Exact counts and estimates
The OpenAI counts are exact for the text itself. A real chat request adds a few tokens for message roles and formatting, so the total your provider reports can be slightly higher than the count for your text alone.
Claude, Gemini and Llama use their own tokenizers. This tool does not run them, so the numbers for those models are estimates: the character count divided by about 3.5, 4 and 3.8 characters per token. English prose usually lands within a modest margin of that. Code, numbers and non-English text often need many more tokens, so the estimate can be well off. When the exact figure matters, use the model provider's own counter.
Why token counts differ between languages
Tokenizers are trained mostly on English text, so common English words are one token while text in other scripts is split into smaller pieces. The newer o200k_base encoding has a larger vocabulary and usually needs fewer tokens for non-English text than cl100k_base.
Privacy: how it works
- Counting happens in your browser. Your text is not sent to Ulkaa or to any provider, and no model file is downloaded.
Tips
- Use the encoding that matches your model. The wrong one can be off by a large margin on non-English text.
- Trailing spaces and line breaks are tokens too. Trim a prompt before counting if you will trim it before sending.
- Keep a margin below a context limit, because the answer also uses tokens.
- A rule of thumb for English is about four characters or three quarters of a word per token, but check with the real count.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your text are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your text are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What is a token?
A token is a chunk of text that a language model reads as one unit: a short word, part of a longer word, a number or a punctuation mark. Context limits and prices are counted in tokens.
Is the count exact?
For the OpenAI encodings, yes: it uses the real tokenizer for the text you paste. Chat requests add a few tokens for roles and formatting. For Claude, Gemini and Llama it is an estimate and is labelled that way.
Which encoding should I choose for GPT-4o?
o200k_base. GPT-4 and GPT-3.5 Turbo use cl100k_base.
Can it count Claude or Gemini tokens exactly?
No. Their tokenizers are not available to run in this page, so it shows an estimate from a characters-per-token ratio and says so. Use the provider's own counter for an exact figure.
Why are there no built-in prices?
Provider prices change often. A stored price would soon be wrong, so you type the current price per 1 million tokens and the cost is worked out from it.
How many words is 1000 tokens?
For ordinary English, about 750 words. The ratio changes with the text, so paste yours to see the real numbers.
Why does my non-English text use so many tokens?
Tokenizers are built mostly from English text, so other scripts are split into smaller pieces. Try o200k_base, which is usually kinder to them than older encodings.
What are the token ids?
Each token is a number in the model's vocabulary. The model works with these numbers, and the ids shown here are the same ones the tokenizer produces.
Popular Token Counter pages
- GPT-4o Token CounterAn exact token count for GPT-4o prompts, using the o200k_base encoding.
- ChatGPT Token CounterPaste a conversation and see how many tokens it uses, with cl100k_base.
- GPT-3 Token CounterToken counts for text-davinci-003 and Codex, using the p50k_base encoding.
- GPT-2 and Davinci Token CounterToken counts with r50k_base, the encoding of the original GPT-3 models.
- Claude Token CounterA labelled estimate of Claude tokens, next to an exact OpenAI count for comparison.
- Gemini Token CounterA labelled estimate of Gemini tokens for mixed-script text.
- Llama Token CounterA labelled estimate of Llama tokens for code and prose.