How LLM Tokens Work: BPE Encodings, Context Windows and Estimates
Learn what subword tokens are, why OpenAI o200k_base counts differ from Claude or Gemini, and how to trim prompt bloat.
Updated 2026-11-28
Tokens are subword pieces, not words
Modern language models split text using Byte-Pair Encoding (BPE) or SentencePiece vocabularies. Common English words take one token, while punctuation, JSON formatting, non-Latin scripts, and rare identifiers split into multiple tokens.
Exact tokenizers vs estimates
Because OpenAI publishes `o200k_base` and `cl100k_base` vocabularies, client-side tools can compute exact token IDs offline. Models from Anthropic, Google, and others use distinct tokenizers, so offline counts for those providers should be treated as estimates unless queried via their official token-counting APIs.
Try the related tools
LLM Token Counter
Exact OpenAI o200k/cl100k token counts plus labelled estimates for Claude, Gemini and Llama.
LLM API Cost Calculator
Compare monthly LLM API costs with prompt caching, batch discounts and editable model prices.
JSON Minifier
Compress JSON by stripping whitespace and comments while tracking byte savings.