How tokenization works
Before a language model can read a sentence, a tokenizer matches pieces of the string to entries in an encoding vocabulary. It replaces those pieces with token IDs. The model then predicts the next token ID from the sequence it has received.
Modern text tokenizers often use byte-pair encoding–style vocabularies. They learn common chunks so familiar sequences can be represented efficiently, while uncommon text can still be broken into smaller pieces. Whitespace and punctuation are part of the input, so they can change the result too.
Text is not split by words alone
A leading space, punctuation mark, emoji, URL, or number can become its own token or change the token boundary around it.
Encodings make counts differ
The same text can have a different token total in o200k_base and cl100k_base because their vocabularies are not identical.
Code deserves a real count
Identifiers, indentation, punctuation, and repeated syntax make code especially unreliable to estimate from plain word counts.
A local encoding example
Tokens Calculator ships two browser-safe encodings. They are a practical way to compare text size without a server request.
o200k_base
Used for the GPT-4o reference. Its vocabulary can group text differently from older encodings.
cl100k_base
Used for the GPT-4 reference and clearly labeled Claude/Gemini-compatible planning estimates.
Compare an actual text sample
Use the multi-model page to see o200k_base and cl100k_base results side by side, with clear labels for approximation-only rows.
Compare token counts