OpenAI token counter
This page runs o200k_base, the tokenizer behind current GPT models, directly in your browser. The count is exact, and your text never leaves the page.
Why this count is exact
OpenAI open-sourced its tokenizers. o200k_base is the encoding used by the current GPT model families, and the same byte-pair encoding that runs on OpenAI's servers runs here as a bundled JavaScript library. Nothing is estimated and nothing is uploaded: the first time you type, the tokenizer loads (about 1 MB compressed), and every count after that is computed locally.
What affects GPT token counts
- English prose lands near the rule of thumb, roughly 0.75 words per token.
- Code tokenizes denser in symbols: indentation, brackets, and identifiers often cost more tokens per visible character.
- Non-English text generally costs more tokens per word, sometimes several tokens per character in CJK languages.
- Structured data like JSON carries token overhead in every quote, brace, and key repetition.
The tokens-per-word figure under the counter tells you how your specific text behaves, which is more useful than any general ratio. For converting round numbers both directions, use the tokens-to-words converter.
Counting is half the cost question
The other half is price. Cached input on OpenAI models bills at a steep discount to fresh input, so the same token count can cost very different amounts depending on how much of your prompt repeats between requests. Current list prices and a calculator that models the cached share are on the OpenAI API pricing page. Context limits for each model are at GPT-5 and GPT-4o context windows.
Other counters: Claude · Gemini · methods in how we count