Stage 2 · Teens · Foundations

Tokens & Tokenization

How raw text gets converted into the units a model actually processes.

Models don't read text as letters or words — they read tokens. A token might be a whole word, part of a word, a punctuation mark, or even a single character, depending on how common that chunk of text is.

Splitting text into tokens is called tokenization. It's the very first step in getting text into a model, and the very last step in getting the model's output back into readable text.

Tokenization
"Learning is powerful!"
Learn
ing
is
power
ful
!
Hover a token to see its numeric ID — this is what the model actually sees.
  • Common words are often a single token (e.g. "the", "is").
  • Rarer or longer words get split into subword pieces (e.g. "tokenization" → "token" + "ization").
  • Whitespace, punctuation, and even emoji all become tokens too.
📝

Model pricing and context limits are measured in tokens, not characters or words. A rough rule of thumb for English is ~1.3 tokens per word (about 4 characters per token). Code, other languages, and odd formatting can be much worse. Always treat this as an estimate, not a conversion formula.

Tokenization is also more literal than it looks. The same word can tokenize differently depending on capitalization or whether it's preceded by a space — a leading-space " hello" (as it would appear mid-sentence) and a capitalized "Hello" (as at the start of a sentence) don't necessarily map to the same token as plain "hello". This matters in practice: it's part of why token counts — and therefore cost — can shift slightly depending on exact formatting, not just word count.

Tokenization Quirks & Cost
"hello"
hello
1 tok
" hello"
hello
1 tok
"Hello"
Hello
1 tok
" Hello"
Hello
1 tok
Real tokenizers learn their vocabulary from data, and a leading space or a capital letter can shift a word onto a completely different, less common token — or split it into more pieces. That's why the same word can cost a different number of tokens depending on exactly where and how it appears.

See how casing/spacing shifts token boundaries, and estimate cost for a real document length.

Worked example. A typical page of English prose is roughly 500 words. Using ~1.3 tokens per word, a 10-page document is about 500 × 10 × 1.3 ≈ 6,500 tokens. At an illustrative rate of $3 per million input tokens, that's about $0.02 to send the whole document once. That looks trivially cheap — but an agent that re-sends the same 10-page document as context on every one of 50 calls in a session is now paying for it 50 times over, which is exactly the kind of cost that motivates techniques like prompt caching and retrieving only the relevant section instead.

Try Your Own Text
Understanding tokenization is foundational!
10 tokens for 43 characters. This is a simplified illustration — real tokenizers (like BPE) learn subword splits from data, but the idea is the same: break text into reusable chunks.

Try tokenizing your own sentence.

Check your understanding
1. Why do models use subword tokens instead of whole words only?
2. In the cost example, why might re-sending the same 10-page document on every call in a 50-call session be worth optimizing away?
All lessons in Stage 2: How AI works