GPT Token Counter
Count tokens for GPT-4o, o1 and o3 (o200k_base encoding) instantly, entirely in your browser.
What is a token, and why does it matter for cost? →What counts as a token?
GPT models don't read text character by character or word by word — they read it as a sequence of tokens produced by Byte Pair Encoding (BPE), a compression algorithm trained on huge amounts of text to find the most common byte sequences.
A token can be a whole common word ("the"), part of a longer word ("token" + "ization"), a punctuation mark, or a whitespace-prefixed word. As a rough rule of thumb, one token is about 4 characters or 0.75 words of English text, though this varies a lot by language and content.
Why token counts matter
API pricing for GPT models is per token, for both the prompt sent and the completion returned — so token count translates directly into cost.
Every model also has a fixed context window measured in tokens (input + output combined). A prompt that fits comfortably as "a page of text" can still exceed the limit once code, JSON, or non-English text pushes the token-per-character ratio higher than plain English prose.
Scope of this tool
This counter uses OpenAI's real o200k_base encoding (the tokenizer used by GPT-4o, o1 and o3), so counts match what the OpenAI API actually bills for those models. It does not cover Claude or Gemini: Anthropic ships no offline tokenizer for Claude 3 and later (their Count Tokens API requires a network call and an API key), and open-weight models like Kimi K2 have no lightweight browser-compatible tokenizer available today.