Topic 1 of 5 · 3 min read
How text splits into tokens
Goal: Given a sentence in a tokenizer view, predict roughly where it splits and explain why common words are one token and rare words several.
A token is a chunk of text, usually a whole common word or a piece of a rarer one, and it is the only unit a language model ever sees. The model never reads letters or words. It reads a list of numbers, one for each token.
Check yourself · 1 of 3
Which description of a token is closest to the truth?
Why it matters
Everything you do with a chat assistant is counted in tokens: the length of your prompt, the length of the answer, the price and the limit on how much the model can hold. If you do not know what a token is, those numbers make no sense. It also explains odd behaviour, such as a model that handles "dog" easily but stumbles on a long made-up name.
How text becomes tokens
A program called a tokenizer cuts the text before the model sees it. It uses a fixed list of chunks, built in advance by finding the pieces that appear most often in a huge amount of text. Then it follows three simple habits:
- Common words are one token. "the", "water" and "house" each have their own entry. Many words are written with a leading space, and that space is usually part of the token.
- Rare words are split into pieces. A word the list does not know is cut into smaller known chunks. A name such as "Zorvanteq" might become four or five pieces.
- Punctuation, digits and line breaks count too. A comma is usually its own token. A long number is often cut into groups of one to three digits.
If nothing else fits, the tokenizer falls back to single characters or even raw bytes, so any text can be encoded.
Different model families use different lists. Claude, ChatGPT, Gemini and open-weight models such as Llama each have their own tokenizer, so the same sentence can give slightly different counts. Compare them side by side in a tokenizer playground.
Before and after
Weak idea: "A token is one word, so a 500-word email is 500 tokens."
Better idea: "A token is a piece of a word. Common words are one token, rare words are several, and spaces and punctuation add more. A 500-word English email is somewhat more than 500 tokens."
For a quick picture, here is how a tokenizer might cut one line. The exact splits depend on the model.
| Text | Likely tokens | Why |
|---|---|---|
| The cat sat. | "The", " cat", " sat", "." | All common words, plus the full stop |
| unbelievably | "un", "believ", "ably" | Rarer word, three known pieces |
| Zorvanteq | "Z", "or", "van", "te", "q" | Made-up name, many small pieces |
What goes wrong
- People assume one word equals one token and under-count the cost of long or technical text.
- People assume every model counts the same. A count from one tokenizer is only an estimate for another.
- People forget the hidden parts. The system instructions, earlier chat messages and any pasted files are tokens too.
Examples
One sentence, two views
Take the sentence "The invoice is overdue." A tokenizer will most likely give five tokens: "The", " invoice", " is", " overdue" and ".". Now take "The invoice is overdue, Mr Wojciechowski." The first part stays the same, but the surname breaks into four or five pieces. Same length in words, more tokens.
Try it yourself
Open a tokenizer playground such as the OpenAI Tokenizer or Tiktokenizer. Paste one ordinary paragraph, then paste a paragraph full of product codes and names. Compare the token count against the word count. The second paragraph will show a much larger gap.
Key points
- A token is a chunk of text, not a letter and not always a word.
- Common words are usually one token; rare words, names and unusual spellings split into several.
- Spaces, punctuation, digits and line breaks all use tokens.
- Each model family has its own tokenizer, so counts differ a little between Claude, ChatGPT, Gemini and open-weight models.
- A tokenizer playground shows the exact split and count for any text.
Common mistakes
- Treating tokens and words as the same thing.
- Assuming a count from one tokenizer is exact for every model.
- Forgetting that system instructions, chat history and pasted files also use tokens.
- Believing the model reads individual letters.
Check yourself · 2 of 3
A tokenizer shows "cat" as one token and "Zorvanteq" as five. Why?
Check yourself · 3 of 3
You paste the same paragraph into the tokenizers of two different model families. What is most likely?
Practice items, not counted towards your mastery.
Start here
- Tokenizer (OpenAI) (opens in a new tab)ToolFree
Paste any text and see the token boundaries and count, coloured piece by piece.
- Tiktokenizer (compare tokenizers) (opens in a new tab)ToolFree
Switch between model tokenizers and see how the same text splits differently.
- Andrej Karpathy: minbpe and the GPT tokenizer lecture (opens in a new tab)ToolFree
A small tokenizer you can read, plus the lecture in text and video form on why spelling, arithmetic and non-English text go wrong.
More for this topic
- Byte-Pair Encoding tokenization (Hugging Face LLM course) (opens in a new tab)CourseFree
A worked example of how merge rules turn a word list into a vocabulary of pieces.