token
Imagine you sent a neural network the same short phrase about morning tea, first in English and then in Tamil. The meaning is the same, the length is almost the same, yet the bill for the second would have been sixteen times larger if you were asking a 2019 model. Today’s model would charge less, but still almost twice as much. The model sees neither letters nor words: it sees tokens, pieces of text from its vocabulary, and it is paid for exactly those. Why some languages got large pieces and others small ones, you will find out below.
A token is used to measure almost everything in work with language models: the price of a request, the size of the context window, the speed of a reply and the amount of data a model was trained on. That is why this sheet has real tokenizers of three generations and thirty-six languages, a counter for your own text, a price calculator and a workshop where you can see why a table in JSON costs three times as much as the same table in CSV.
Counter and conversion
Paste your text
You can paste a letter, a prompt, a piece of code or a table here. The count is done by the real OpenAI vocabularies, the same ones used in the models; the vocabulary loads on the first change to the text, about two megabytes. Below, the text is cut into tokens: each coloured rectangle is one token.
Words and pages into tokens and money
When there is no text yet but you need a budget right now, enter the amount and choose a language. The conversion relies on the measured token density of each of the thirty-six languages, so it is an estimate accurate to ten or twenty percent, not an exact count.
Etymology
A sign, a coin and a piece of bytes
In a thousand years the word token has been an omen, a coin for the fare, a building block of a program and, finally, a unit for counting in neural networks. But in all its lives it has meant one thing: a small object that stands in for something larger. A coin stands in for money; a token in a model’s vocabulary stands in for a piece of text.
01 · Definition and the path of a word
The model reads not letters but numbers
A neural network can only handle numbers. So before it sees your question, the text passes through a tokenizer: it turns the text into UTF-8 bytes, then greedily glues the bytes into the longest pieces found in its vocabulary and replaces each piece with a number. The result is a chain of integers, for example 10346 for the word token. From then on the model works only with these numbers, and at the end the tokenizer turns the numbers of the reply back into text.
The vocabulary is compiled in advance, on an enormous heap of texts: frequent combinations get their own number, rare ones are assembled from pieces. That is why a token is not an exact measure like the metre, but a measure tied to a vocabulary. The same paragraph will take a different number of tokens in GPT-2 and in GPT-4o, and when comparing the prices of different models it is always worth asking whose tokens they are counted in. For estimates, averages serve: in English there are about four characters per token, or three quarters of a word.
How a word becomes a number
Choose a word and a vocabulary. The top row is the characters as you see them; the second is the UTF-8 bytes in hexadecimal; the third is the pieces into which the vocabulary has cut the bytes; the bottom is the numbers of those pieces. Pink marks tokens that cut a character in half: they hold only part of a letter.
Why Tamil cost sixteen times more
A tokenizer’s vocabulary is assembled from what occurs most often in the training texts, and most of them are written in English. English words therefore get their numbers whole, together with the space in front. Tamil letters take three bytes each in UTF-8, and if the vocabulary has never seen a needed combination, all it can do is cut the text by one or two bytes. That is how our phrase about morning tea, twenty-one tokens in English, turned into 347 tokens in the GPT-2 vocabulary.
Each new generation of vocabularies was trained on more and more multilingual texts and made larger. In the GPT-4 vocabulary the same phrase needed 170 tokens, and in the GPT-4o vocabulary 39. The inequality has shrunk but not vanished: Tamil, Hindi, Korean and Greek still use more tokens than English, which means their speakers pay more and hit the context window sooner. Try any of the thirty-six languages in the lab below.
Cut, train, count
In the “Cut” experiment one phrase is translated into the thirty-six languages of the site, and real vocabularies of three generations cut it: GPT-2, GPT-4 and GPT-4o. Tap any piece to see its number and bytes. In the “Train” experiment you grow a vocabulary yourself: each move of the slider glues together the most frequent pair of neighbouring pieces, as the BPE algorithm does. And in the “Numbers” experiment you see how vocabularies tear dates, prices and long numbers to pieces, and why models are so bad at mental arithmetic.
02 · Orders of magnitude
From one “yes” to fifteen trillion
Drag the slider: it runs on a logarithm, and each division is ten times more than the one before. You will go from a short reply through a page, a novel and Wikipedia to the mountains of text on which modern models are trained. Note that in training any model has read tens of thousands of times more words than a person can speak in a whole lifetime.
03 · Format workshop
One table, six prices
The five largest cities in the world with population and area — the data is the same, only the packaging changes. Choose a format and you will see the text itself and how many tokens it takes in each of the three vocabularies. The numbers here were counted by real tokenizers. Quotation marks, brackets, indents and repeated field names are all tokens you pay for, though they add no meaning.
04 · Tokenizers of the world
Every model has its own vocabulary
Vocabularies are growing: in six years they became four to five times larger, and almost every time for the sake of other languages and program code. Note that the multilingual models — BLOOM, mT5, Gemma — started right away with vocabularies of a quarter of a million tokens. The table collects the vocabularies whose sizes are published; where a number is rounded, there is a ≈ sign. Tap a row to read the details.
Three lines worth knowing
Counting tokens “by eye” from string length is risky: in JavaScript the length of a string is counted in sixteen-bit units, not in bytes and not in tokens. It is more reliable to take the same vocabulary as the model’s. Here is how it is done in the three most common environments.
{code}The most accurate count comes in the API reply, in the usage field: how many tokens were on input, on output, and how many were taken from the cache. Check your estimates against it at least once for every new model.
05 · Writing rules
06 · Neighbouring units
07 · Historical section
In early 2023 the researchers Jessica Rumbelow and Matthew Watkins noticed that the GPT-3 models could not repeat the simple word SolidGoldMagikarp. Ask, and the model would answer “distribute”, start insisting that there is no such word, or even take offence. The explanation was found in the vocabulary. That was the name of one of the most active members of the Reddit forum where people simply counted in turn to infinity, and his nickname appeared thousands of times in the texts from which the vocabulary was compiled. The nickname received its own token, number 43453.
But that forum hardly made it into the texts on which the model itself was later trained. The vocabulary cell existed, but the model almost never saw it and did not know what it meant. Such “glitch tokens” became a lesson: the vocabulary and the model must be trained on similar data. In the GPT-4 vocabulary this nickname is already cut into five ordinary pieces, and the model repeats it without trouble.
Series · AI
units of language modelsHow a neural network is measured
The token is the first and smallest measure in this series. The context window and the price of a reply are built from tokens, models learn on tokens, and the number of parameters and operations shows how much labour goes into each of them. On the left is a console where these measures meet in one request; on the right are the sheets of the series.
Catalogue of quantities
the whole index →The seven SI base units
A drop of acid changes the colour of the juice, salt colours the flame, water freezes at a tap. Below them are all Simetrium sheets, by discipline and alphabetically.
Open the index →





