LLM Token Counter
A free token counter for LLM prompts. Pick your model from GPT, Claude, Gemini, DeepSeek, Qwen or Llama, paste any text and see the token count, every token highlighted and a comparison across models.
| Model | Tokens | Count |
|---|
Anthropic, Google and the other providers do not publish a tokenizer that runs in the browser, so their numbers are estimates from published characters-per-token ratios and can be off by 20% or more, especially for code and non-English text.
Count Tokens Before You Send a Prompt
Language models do not read characters or words. They read tokens, and every limit and price is measured in them: context windows, output limits, rate limits and the bill at the end of the month. This LLM token counter shows how many tokens your text uses before you send it.
For OpenAI models it runs the real tokenizer (OpenAI’s open-source BPE ranks via js-tiktoken) in your browser, so the count is exact for those encodings and your text is never uploaded. Each token is highlighted in color, and you can see the token IDs. For Claude and Gemini it shows estimates based on the providers’ published ratios.
How to count tokens
- Paste your text into the box: a prompt, a system message, a document or code. Click Load sample to try it first.
- Pick your model from the list, grouped by provider. The badge next to it tells you how the number is counted: Exact, Near-exact or Estimate.
- Read the count. The token count, characters, words and characters per token update as you type, and the Compare all models table shows the same text for every model. The first time, the tokenizer data (about 1.5 MB) is downloaded once and then cached by your browser.
- Inspect the tokens. The colored view shows exactly where the text is split. Tick Show token IDs to copy the numeric IDs.
What is a token?
Modern LLMs use byte pair encoding (BPE). The tokenizer starts from the raw bytes of your text and repeatedly merges the most frequent pairs it learned during training, so frequent words and word pieces become single tokens and rare strings are split into several. Leading spaces usually belong to the token that follows them, which is why " world" with its space is one token.
Because of this, there is no fixed number of characters per token. English prose averages around four characters per token with OpenAI’s tokenizers, while code, numbers, URLs, emoji and many non-Latin scripts need more tokens for the same length. That is why counting with the real tokenizer matters when you are close to a limit.
Token count examples (o200k_base)
| Text | Characters | Tokens | Why |
|---|---|---|---|
Hello world | 11 | 2 | Two common words; the space joins the second token |
tokenization | 12 | 2 | A less common word is split into pieces |
2026-11-20 | 10 | 6 | Digits are grouped in chunks of up to three, dashes are separate |
🚀 | 1 | 2 | The emoji is 4 bytes in UTF-8 and is split into byte-level tokens (3 in cl100k_base) |
Paste any of these into the counter to see the split. Results differ between o200k_base and cl100k_base; the newer encoding has about 200,000 entries instead of 100,000, so it usually needs fewer tokens, especially for non-English text.
Exact, near-exact and estimated counts
| Badge | Models | How it is counted |
|---|---|---|
| Exact · o200k_base | GPT-5, GPT-5 mini and nano, GPT-4.1, GPT-4o, o3, o4-mini | OpenAI’s published tokenizer for these models, run in your browser |
| Exact · cl100k_base | GPT-4, GPT-3.5 Turbo, text-embedding-3 | OpenAI’s older published tokenizer |
| Near-exact · o200k_base | GPT-6.x, GPT-5.5, GPT-5.4 | OpenAI has not published which tokenizer these use, so the latest public one is used; check the usage field of an API response for the billed number |
| Estimate | Claude, Gemini, DeepSeek, Qwen, Kimi, GLM, Llama | Characters divided by a published characters-per-token ratio (see below) |
How the estimates for other models work
Anthropic, Google and the open-weight model providers do not publish tokenizers that can run in a browser, so this tool never shows an exact count for them. The estimates use the providers’ own statements:
| Models | Rule used | Source |
|---|---|---|
| Claude Opus 4.7 and later | characters ÷ 2.5 | Anthropic: 1M tokens is roughly 2.5M Unicode characters on the current tokenizer |
| Claude Sonnet 4.6, Haiku 4.5 and older | characters ÷ 3.25 | Anthropic: the newer tokenizer produces about 30% more tokens for the same text |
| Gemini | characters ÷ 4 | Google: a Gemini token is about 4 characters |
| DeepSeek, Qwen, Kimi, GLM, Llama | characters ÷ 4 | General rule of thumb for English text with modern BPE tokenizers; expect more tokens for code and non-English text |
For an exact number, use the free token counting endpoints: Anthropic’s /v1/messages/count_tokens and Gemini’s countTokens. Every API response also reports the billed tokens in its usage field.
Tips to use fewer tokens
- Remove noise. Repeated boilerplate, long HTML markup and pretty-printed JSON indentation all cost tokens. Minified JSON is often much shorter.
- Put stable text first. A long system prompt that does not change can be cached by the provider, and cached input is billed at a fraction of the normal price.
- Check hidden characters. Text copied from the web can contain zero-width and other invisible characters that add tokens. Clean them with the Invisible Character Cleaner.
- Budget for output. Output tokens usually cost several times more than input tokens. Estimate the full bill with the LLM Cost Calculator.
Frequently Asked Questions
Common questions about counting LLM tokens.
For English prose with OpenAI’s tokenizers it is usually somewhere around 1,150 to 1,400 tokens, but it depends on the vocabulary. Code, numbers and non-English text use more. Paste your own text above for an exact count.
Yes for the selected encoding. The page runs js-tiktoken with OpenAI’s published o200k_base and cl100k_base ranks, which produce the same token IDs as OpenAI’s tiktoken library. Chat requests add a few tokens per message for formatting, so the billed input can be slightly higher.
OpenAI documents o200k_base for GPT-4o, GPT-4.1, GPT-5 and the o-series. It has not published the tokenizer of GPT-5.4, GPT-5.5 or GPT-6.x, so those are marked Near-exact and counted with o200k_base, the latest public tokenizer. Check the usage field of an API response for the billed number.
Anthropic, Google and the other providers do not publish a tokenizer that runs in the browser. The estimates use published ratios of characters per token. For an exact number, call Anthropic’s count_tokens endpoint, Gemini’s countTokens method, or check the usage field returned by the API.
No. Tokenization runs entirely in your browser. Only the tokenizer data file is downloaded from the jsDelivr CDN; your text never leaves the page.
Each encoding has its own vocabulary. cl100k_base has about 100,000 entries and o200k_base about 200,000, so o200k_base can represent more words and scripts as single tokens.
Often, yes. An emoji takes up to 4 bytes in UTF-8 and is frequently split into two or more byte-level tokens; combined emoji such as family or flag sequences use even more. Invisible characters such as zero-width spaces also count.
The context window is the maximum number of tokens a model can handle in one request, input and output together. Check a prompt against current models with the Context Window Checker.