A REAL TOKENIZER · TRAINED LIVE IN YOUR BROWSER · 0 LIBRARIES

HOW
MACHINES
READ

Before an AI model can predict a single word, your text must become numbers. The chopping-up step is called tokenization — and it explains token pricing, context windows, and why models famously miscount the r's in "strawberry". On this page a real tokenizer learns its vocabulary in front of you, then reads your own words.

WATCH IT LEARN → TOKENIZE MY TEXT
01

The problem: models eat numbers, not letters

A neural network is arithmetic — weights times inputs. So the very first step of any language model is brutal: convert text into a sequence of numbers.

The unit of conversion is the . A tokenizer owns a fixed — a numbered list of text chunks — and its whole job is to rewrite your sentence as a list of IDs from that list. The model never sees your letters again; it sees ID 4013 ID 88 ID 1729

So what should the chunks be? Whole words fail (there are infinitely many: names, typos, "unbelievableness"). Single characters work but make every sentence painfully long. The answer used by essentially every modern model is a 1994 compression trick adapted for translation in 2016: . It learns the chunks from data, and the algorithm is almost embarrassingly simple:

1. start with single characters
2. count every adjacent pair in the training text
3. glue the most frequent pair into one new chunk  // "t"+"h" → "th"
4. repeat until the vocabulary is big enough

Frequent words end up as single tokens. Rare words shatter into pieces. Nothing is ever unrepresentable — worst case, a word falls all the way back to characters. Frontier models run exactly this recipe with vocabularies of 100,000–200,000 chunks learned from terabytes of text. The tokenizer below runs it on a 3-kilobyte corpus, live, so you can watch every step.

02

Watch it learn its vocabulary

This is the training corpus — the only text the tokenizer will ever learn from. Each merge welds the most frequent adjacent pair into a new vocabulary entry. Hit MERGE ONCE and watch English structure assemble itself, greediest pair first.

THE TRAINING CORPUS — ALL OF IT

The · marks the end of a word — it lets the tokenizer learn that "s·" (an s that ends a word) is a different animal from an s in the middle.

MOST FREQUENT ADJACENT PAIRS, RIGHT NOW
merges learned0
vocabulary size0
corpus in tokens0
THE MERGE LOG — NEWEST FIRST
No merges yet. The vocabulary is bare characters.
WHAT TO WATCH FOR

The first merges are always the gluey bits of English: t+h, e+·, i+n. Then suffixes crystallize (ing·, er·, ), then whole common words fuse into single tokens (the·, and·). Watch the "corpus in tokens" number fall with every merge — a tokenizer is, at heart, a compressor. That is not a metaphor: the algorithm was invented for file compression in 1994, and researchers increasingly think compression and understanding are two faces of the same coin.

03

Now it reads your text

Type anything. The tokenizer applies its learned merges — in the order it learned them — and shows exactly what a model would receive. Every coloured chip is one token: one ID, one "word" in the machine's private language.

INPUT — YOUR TEXT
OUTPUT — WHAT THE MODEL ACTUALLY SEES
characters0
tokens0
chars per token
cost at $5/1M tokens*
using merges0

*Illustrative price. Real prices vary by model — but they are all quoted per million tokens, which is why this page matters to your bill. Fewer merges learned → more tokens → higher cost: try tokenizing before and after training.

Some experiments worth a minute: common vs rare — "the" is one token, but a rare word shatters into fragments, because the tokenizer never saw it enough to build it. Typos — "netwrok" costs more tokens than "network"; a typo literally makes text more expensive and harder for the model to read. Word families — notice how "network", "networks" and "networking" share chunks: the model gets morphology half for free.

04

Why tokens explain so much

Once you know models see token chunks — never letters, never quite words — a whole family of AI folklore stops being mysterious.

  • The strawberry problem. Ask a model to count the r's in "strawberry" and it often stumbles — because it never sees r's. It sees something like strawberry: two opaque IDs. Asking it to count letters is like asking you to count the brushstrokes in a photo of a painting. (Modern models mostly fixed this by learning to spell out words first — reasoning their way around their own eyesight.)
  • Context windows. "This model handles 200K context" means 200,000 tokens — roughly 150,000 English words. The window is the model's entire working memory, and it's budgeted in tokens, which is why long documents get summarized or truncated.
  • Pricing. API prices are per million tokens, in and out. Verbose prompts cost real money; so do rare words, typos and unusual formatting, each inflating the token count.
  • Languages aren't equal. A tokenizer trained mostly on English packs English tightly but shreds other scripts into many more tokens per sentence — so the same meaning can cost several times more in Burmese than in English, and eats context window faster. Tokenizer training data quietly decides who gets cheap AI.
  • Numbers are weird. "2026" might be one token but "20261" three. Arithmetic on top of arbitrary chunk boundaries is genuinely harder — one reason calculators remain better than language models at long division.
HONESTY BOX — WHAT'S DIFFERENT AT FRONTIER SCALE

Real tokenizers are this exact algorithm with three upgrades: they start from bytes rather than characters (so emoji, Chinese, code — anything — is representable and nothing is ever "unknown"); they use pre-tokenization rules to decide where merges may cross spaces and punctuation; and they add special tokens marking things like the start of a conversation turn. GPT-2 2019 shipped byte-level BPE with 50,257 tokens; current frontier vocabularies run 100K–200K. The learning algorithm you just watched is the same one.

Tokens are how text gets into the machine. What the machine does with them — every token looking at every other token to work out what matters — is the subject of the companion page: The Attention Microscope. And the mathematics underneath it all lives at How Machines Learn.