AI Token Counter for GPT, Claude, Gemini and Llama
Exact OpenAI token counts plus estimates for other models.
| Tokenizer | Tokens | 8K | 32K | 128K | 200K | 1M |
|---|---|---|---|---|---|---|
| OpenAI o200k_baseGPT-4o, GPT-4.1, GPT-5, o-series | ... | - | - | - | - | - |
| OpenAI cl100k_baseGPT-4, GPT-3.5 Turbo, text-embedding-3 | ... | - | - | - | - | - |
| Claude (estimate)About 3.5 characters per token | ~0 | 0% of 8K, fits | 0% of 32K, fits | 0% of 128K, fits | 0% of 200K, fits | 0% of 1M, fits |
| Gemini (estimate)About 4 characters per token | ~0 | 0% of 8K, fits | 0% of 32K, fits | 0% of 128K, fits | 0% of 200K, fits | 0% of 1M, fits |
| Llama 3 (estimate)About 4 characters per token | ~0 | 0% of 8K, fits | 0% of 32K, fits | 0% of 128K, fits | 0% of 200K, fits | 0% of 1M, fits |
0 characters, 0 words, 0 lines. OpenAI counts are exact for raw text; rows marked ~ are rough estimates. Percentages show how much of each context window the text uses.
Use via API
Count LLM tokens in text: exact counts for OpenAI's o200k_base and cl100k_base tokenizers, estimates for Claude, Gemini and Llama, and how much of common context windows it fills. Send JSON, get JSON back.
POST https://pithlab.com/api/v1/tools/ai-token-counter
curl https://pithlab.com/api/v1/tools/ai-token-counter \
-H "Authorization: Bearer $PITHLAB_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"PithLab counts tokens the way GPT-4o does."}'About the AI Token Counter
Count tokens exactly for OpenAI o200k_base and cl100k_base, with labelled estimates for Claude, Gemini and Llama, and check which context windows your prompt fits.
How to use the AI Token Counter
- Paste your prompt, document or chat transcript.
- Read the exact OpenAI token counts and the estimates for Claude, Gemini and Llama.
- Check the context window table to see whether the text fits in 8K up to 1M token windows.
- Tick Show tokens to see how the text is split, and copy the token IDs if you need them.
Examples
Input
The quick brown fox jumps over the lazy dog.
Output
o200k_base: 10 tokens, cl100k_base: 10 tokens, 44 characters, 9 words
Input
你好,世界
Output
o200k_base: 3 tokens, cl100k_base: 6 tokens, 5 characters, 2 words
Frequently asked questions
Which counts are exact?
The two OpenAI counts. They use the open source gpt-tokenizer library, which implements the same o200k_base and cl100k_base encodings as OpenAI's tiktoken. o200k_base is used by GPT-4o, GPT-4.1, GPT-5 and the o-series, and cl100k_base by GPT-4 and GPT-3.5 Turbo.
How are the Claude, Gemini and Llama numbers worked out?
They are estimates, not real tokenizer output. Characters are divided by about 3.5 for Claude and about 4 for Gemini and Llama 3, and each Chinese, Japanese or Korean character counts as one token. Expect them to be off by 10 to 20 percent or more, especially for code and non-English text. Use each provider's token counting API for exact numbers.
Why does a chat API report a few more tokens than this?
Chat APIs wrap every message in formatting tokens for roles and message boundaries, and tools, images and system prompts add more. This tool counts the raw text you paste, so leave some headroom.
What does the context window table show?
For common window sizes from 8K to 1M tokens it shows how much of the window each count would use. Remember that the window usually has to hold the model's reply as well as your prompt.
Is my text sent to OpenAI or anyone else?
No. The tokenizer data loads into your browser and all counting happens on your device. Nothing you paste is uploaded.