LLM Token Counter Online — GPT-4o, GPT-5, GPT-4 — Free
Count exactly how many tokens your text costs with the real OpenAI tokenizers — o200k_base and cl100k_base — not a character estimate.
Frequently Asked Questions
Are these counts exact?
For the OpenAI tokenizers, yes — this runs the actual BPE encoders (o200k_base and cl100k_base), not an approximation. Claude and Gemini use their own tokenizers, which are not published, so their counts will differ somewhat.
Why is the count so different from my character count?
A token averages roughly four characters of English prose, but that average hides enormous variation. Code, JSON punctuation, long identifiers, emoji and non-Latin scripts all tokenize far less efficiently — Chinese or Hindi text can approach one token per character.
Which encoding should I use?
o200k_base for current models including GPT-4o, GPT-4.1 and GPT-5. cl100k_base for GPT-4, GPT-3.5-turbo and the older embedding models. Both are shown so you can compare.
Does the prompt get sent anywhere?
No. The tokenizer runs in your browser, so prompts containing proprietary or personal data stay on your machine.
Why does the tool take a moment the first time?
The BPE rank tables are about a megabyte and are downloaded on first use, then cached by your browser. They are loaded on demand so that the rest of the site is not slowed down by them.
Privacy First: All processing happens directly in your browser. Your data never leaves your device.
About Token Counter
Tokens are the unit that decides what fits in a context window and what an API call costs. They do not track character count in the way people expect, which is why estimating is a reliable way to be surprised by a bill or a truncated prompt.
What a token actually is
Models do not read characters or words. Text is split by a byte-pair encoding algorithm into subword units learned from a training corpus, where common sequences become single tokens and rare ones get broken into pieces. The word "the" is one token; an unusual surname might be four.
The often-quoted rule of roughly four characters per token holds for ordinary English prose and breaks down everywhere else. This tool reports the ratio for your specific input precisely so you can see how far from that average you actually are.
Where the estimates go wrong
- JSON is punctuation-dense, and braces, quotes and colons each consume tokens. A payload can cost far more than its character count suggests — which is the entire premise of formats like TOON.
- Code tokenizes poorly. Long camelCase or snake_case identifiers fragment into several tokens each, and indentation is not free.
- Non-English text is markedly less efficient. Languages written in non-Latin scripts can approach one token per character, so a prompt that fits in English may not fit translated.
- Emoji and unusual Unicode frequently cost several tokens for a single visible character.
- Base64 and hashes are close to worst case: high-entropy strings share almost no learned subwords, so they fragment heavily.
Which encoding applies to your model
o200k_base is the current OpenAI encoding, used by GPT-4o, GPT-4.1 and GPT-5. cl100k_base is the previous generation, used by GPT-4, GPT-3.5-turbo and the widely deployed embedding models. Both are reported here because the same text does not cost the same under each.
Anthropic and Google do not publish their tokenizers, so no offline tool can give exact counts for Claude or Gemini. Anyone claiming otherwise is showing you an approximation. The figures here are a reasonable proxy — the tokenizers are built on similar principles — but treat them as indicative for those models, and use the provider API when an exact number matters.
Counting the prompt is not counting the request
A chat request costs more than the text you paste. Each message carries structural overhead for its role and delimiters, the system prompt is included in every call, and tool or function definitions are part of the input on every request that could use them. Conversation history is re-sent in full on each turn, which is why long threads grow expensive in a way that surprises people.
Output tokens are billed separately and usually at a higher rate. When budgeting a feature, count the prompt here, then account for the system prompt, the tool schemas, the accumulated history and the expected completion length.