What Is This Tool?
Language models don't process text character-by-character or word-by-word — they split it into "tokens", chunks that are often a few characters long (roughly 4 characters or 0.75 words per token in English, though this varies a lot by language and content). Token count directly determines your API cost and whether your prompt fits inside a model's context window.
This tool uses the real tokenizer encodings — o200k_base (used by GPT-4o and GPT-4o mini) and cl100k_base (used by GPT-4 and GPT-3.5) — rather than a rough "characters divided by 4" approximation, so the count you see here matches what you'd actually be billed or limited by.
Why Use It?
- Real tokenizer encodings (o200k_base, cl100k_base) — not a character-count guess.
- Switch models instantly to compare how the same text tokenizes differently.
- Character and word counts shown alongside, for quick reference.
- Updates live as you type or paste — no button to click.
- 100% local — your prompt or document is never uploaded, which matters if it contains proprietary or sensitive text.
How to Use
- Paste or type your text, prompt, or code into the box.
- Pick the model you're targeting (GPT-4o / GPT-4o mini, or GPT-4 / GPT-3.5).
- The token count updates instantly — switch models to compare.
- Use the character/word counts alongside as a sanity check or for non-token-based limits.
Example
Input
"Hello, world!" (GPT-4o encoding)Output
4 tokens, 13 characters, 2 wordsCommon short phrases often tokenize as 1 token per word or punctuation mark, but this varies with capitalization, spacing and language.
Which tokenizer should you check?
The two encodings aren't interchangeable — pick the one matching the model you're actually calling, since the same text can tokenize to a noticeably different count in each.
| Model family | Tokenizer | When to use it |
|---|---|---|
| GPT-4o, GPT-4o mini, GPT-4.1, o1/o3 reasoning models | o200k_base | Any current OpenAI model release — this is the tokenizer OpenAI has shipped for all newer models since GPT-4o. |
| GPT-4, GPT-4-turbo, GPT-3.5-turbo, text-embedding-ada-002 | cl100k_base | Older or legacy OpenAI models, or if your API calls still target GPT-3.5/GPT-4 (not GPT-4o) for cost reasons. |
| Claude, Gemini, Llama, other non-OpenAI models | Neither — not covered here | These providers use their own tokenizers (not tiktoken-based); counts here won't match their billing. |
Practical tips
- Estimating API cost before sending a request: multiply the token count by your model's per-token price to get a quick cost estimate, rather than guessing from character count.
- Checking if a long document fits in a model's context window: paste the whole thing here first — it's much faster than trial-and-erroring an actual API call that fails partway through.
- Comparing prompt-engineering variants: if you're trying to shorten a system prompt to save cost, paste each version here to see the token savings directly, not just "it looks shorter".
- Non-English text: token counts for Chinese, Japanese, Korean and other non-Latin scripts are often much higher per character than English — check this explicitly rather than assuming the 4-characters-per-token rule applies.
Frequently Asked Questions
Why does the same text give a different token count for different models?
GPT-4o and GPT-4o mini use a newer tokenizer (o200k_base) than GPT-4 and GPT-3.5 (cl100k_base) — the two encodings split text into a different vocabulary of chunks, so the exact same input can tokenize to a different count depending on which model you're targeting.
Is 1 token really about 4 characters?
That's a rough average for English prose, but it varies a lot: common English words are often 1 token each, while rare words, code, and especially non-Latin scripts (Chinese, Japanese, Korean, Arabic) can take noticeably more tokens per character. Always check the exact count for anything cost- or limit-sensitive rather than relying on the 4-characters rule of thumb.
Does this tool call the OpenAI API to count tokens?
No. It uses a JavaScript implementation of the same tokenizer encodings (o200k_base, cl100k_base), running entirely in your browser. No API key needed, no network request made, and your text is never sent anywhere.
Why does my token count matter?
Two reasons: API pricing is billed per token (input and output), and every model has a maximum context window measured in tokens — if your prompt plus expected response exceeds that limit, the request fails or gets truncated. Checking token count in advance avoids both surprises.
Does this work for Claude, Gemini, or other non-OpenAI models?
The counts shown are specifically for OpenAI's tokenizers (o200k_base and cl100k_base). Other providers use their own tokenizers, which can give meaningfully different counts for the same text — this tool doesn't cover those.