Token Counter
Count GPT tokens exactly with the OpenAI tokenizers (o200k for GPT-5 and GPT-4o, cl100k for GPT-4) and see how your prompt is split. Runs in your browser.
Runs in your browser · Nothing uploaded · No sign-up
Something not working, or missing a feature? Send feedback
About the Token Counter
The Token Counter counts exactly how many tokens a prompt or document uses with OpenAI's own tokenizers: o200k_base for GPT-5, GPT-4.1, GPT-4o and the o-series, and cl100k_base for GPT-4 and GPT-3.5. It shows how the text is split into tokens and their IDs, so you can stay within context limits and estimate API costs. The text is tokenized in your browser and never sent anywhere.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the Token Counter
- Paste your prompt, system message, document or code.
- Choose the tokenizer of your model: o200k for GPT-5 and GPT-4o, cl100k for GPT-4 and GPT-3.5.
- Read the token, character and word counts.
- Look at the coloured tokens to see where the text splits, or switch to token IDs and copy them.
Which tokenizer each model uses
| Tokenizer | Vocabulary | Models |
|---|---|---|
| o200k_base | ~200,000 tokens | GPT-5 family, GPT-4.1, GPT-4o, GPT-4o mini, o1, o3, o4-mini |
| cl100k_base | ~100,000 tokens | GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, text-embedding-3, text-embedding-ada-002 |
Sources: OpenAI tiktoken
Examples
Input
Hello, world!
Result
4 tokens: "Hello" "," " world" "!"
Input
const total = items.reduce((sum, x) => sum + x.price, 0);
Result
19 tokens with both tokenizers
Input
नमस्ते दुनिया
Result
o200k: 5 tokens · cl100k: 13 tokens
Common mistakes
- Counting characters instead of tokens. Context limits and prices are per token. A JSON payload or minified code can use far more tokens than its length suggests.
- Using the wrong tokenizer. GPT-4 and GPT-4o split text differently. Counts from cl100k are usually higher for non-English text, so choose the tokenizer of the model you call.
Works well with the Token Counter
- Word & Character Counter: count words, sentences and reading time.
- JSON Minifier: shrink JSON before sending it to a model.
- Remove Extra Spaces: remove whitespace that costs tokens.
Frequently asked questions
How many tokens is a word?
For English text, a token is about 4 characters or three quarters of a word, so 100 words are roughly 130 tokens. Code, numbers and other languages use more tokens per word.
Why do Hindi and other languages use more tokens?
Tokenizers learn common character sequences from their training data. The newer o200k tokenizer has many more non-English pieces: "नमस्ते दुनिया" is 5 tokens with o200k but 13 with cl100k.
Does this count tokens for Claude or Gemini?
No. Claude, Gemini and Llama use their own tokenizers, so the same text gives them a different count. Use the count as a rough guide for them; for an exact Claude count, use the token counting endpoint of Anthropic's API.
Are chat messages counted the same way?
Chat APIs add a few tokens per message for the role and separators, so a conversation uses slightly more than its texts alone. Images and tool definitions are counted separately.
Is my text uploaded?
No. The tokenizer (the open-source gpt-tokenizer library) runs in your browser, so prompts with private data stay on your device.
Related tools
Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case and more online. Rename variables and keys in one paste.
Remove Duplicate Lines
Remove duplicate lines from text online, keeping the first occurrence and the original order. Optionally ignore case, extra spaces and empty lines.
Sort Lines
Sort lines of text online alphabetically, naturally (item 2 before item 10), by number or by length, in ascending or descending order. Runs in your browser.
Remove Line Breaks
Remove line breaks from text online: join broken lines from a PDF or email into one paragraph, or into a comma-separated list. Optionally keep paragraph breaks.
Remove Extra Spaces
Remove extra spaces from text online: collapse repeated spaces and tabs, trim every line and squeeze blank lines. Clean pasted text in one click.
Slug Generator
Turn any title into a clean URL slug online: lowercase, accents removed, symbols dropped, words joined with hyphens or underscores. One slug per line.