Tokenization Explained: How LLMs Read Text
SkillVeris Team
AI Research Team

Tokenization splits text into tokens, sub-word chunks that are the actual units a language model reads and predicts.
In this guide, you'll learn:
- Most modern models use sub-word tokenization, which balances a compact vocabulary with the ability to represent any word, including new ones.
- Tokens drive practical realities: context limits, pricing, and speed are all measured in tokens, not words or characters.
- Quirks of tokenization explain many odd model behaviors, from struggling to count letters to handling code and non-English text unevenly.
1What Tokenization Is
Tokenization is the process of splitting text into tokens, the small chunks that a language model actually reads and generates. A model never sees raw letters or whole words the way you do; it sees a sequence of tokens, each mapped to a number. Everything the model does, from understanding your prompt to writing a reply, happens over these numbered tokens.
A token is often a piece of a word rather than a whole word. Common words may be a single token, while rarer or longer words get broken into several. The word tokenization itself might split into a few pieces, each a familiar sub-word fragment the model has seen many times before.
This matters because tokens are the true unit of everything practical about language models. Context length, pricing, and processing speed are all counted in tokens, and many puzzling model behaviors trace directly back to how text was tokenized. Understanding tokens demystifies a surprising amount of how these systems behave.
Think of tokenization as the translation layer between your world and the model's. You write in words and sentences; the model works in numbered chunks. Nothing crosses that boundary without being converted, so the rules of the conversion quietly govern what the model can see, how much it can hold, and what it costs you to ask. That is why a small, unglamorous step deserves real attention.
2Why Not Just Use Words or Letters
You might expect models to read whole words, but that creates problems. A vocabulary of every possible word would be enormous and still miss new words, names, typos, and terms in other languages. Any word not in the vocabulary would be unrepresentable, which is unacceptable for a general system.
The opposite extreme, feeding individual characters, avoids the unknown-word problem but makes sequences very long and forces the model to learn spelling and word structure from scratch. Long sequences are expensive to process and stretch the model's ability to track meaning over distance.
Sub-word tokenization is the compromise that wins. It keeps a manageable vocabulary of common words and word pieces while guaranteeing that any text can be represented by falling back to smaller fragments. This gives compact sequences for common text and graceful handling of anything unusual.
3How Sub-Word Tokenization Works
Sub-word tokenizers are built by analyzing a large body of text and finding which sequences of characters occur together often enough to deserve their own token. Frequent words become single tokens, while rarer words are represented as combinations of smaller, common pieces. The result is a vocabulary that packs common text efficiently.
A widely used family of methods starts from individual characters and repeatedly merges the most frequent adjacent pairs into new tokens, gradually building up from letters to word pieces to whole common words. The final vocabulary is a fixed list, often tens of thousands of tokens, that the model uses for everything.
When the tokenizer encounters new text, it greedily matches the longest known tokens it can, breaking words into the fewest pieces possible. This is why the same word can tokenize differently depending on spacing and context, and why leading spaces are often part of a token.
4From Tokens to Numbers to Meaning
Each token in the vocabulary has a unique integer id, so tokenized text becomes a list of numbers the model can process. These ids are just labels; the meaning comes from the next step, where each id is mapped to an embedding, a vector of numbers that the model learns to represent the token's meaning.
Embeddings are where tokens gain semantic content. Through training, tokens that appear in similar contexts get similar embeddings, so the model captures relationships between word pieces. The model then processes these embeddings through its layers to understand context and predict the next token.
Generation is the reverse: the model outputs a probability distribution over the whole vocabulary, a token is chosen, and it is appended to the sequence before repeating. The text you read is produced one token at a time, then stitched back together and displayed as ordinary characters.
5Tokens and the Context Window
A model's context window is the maximum number of tokens it can consider at once, covering both your input and its output. When people say a model handles a certain length, that length is measured in tokens, not words or characters. Exceeding it means the model cannot see the overflow, so older content must be dropped or summarized.
Because a token is often less than a full word, a rough rule is that a chunk of English text has somewhat more tokens than words, though this varies by content. Code, unusual formatting, and other languages can tokenize far less efficiently, consuming more tokens for the same visible length.
Managing the context window is a core skill in building with language models. Knowing that everything competes for the same token budget explains why long documents must be chunked, why conversations need trimming, and why concise prompts leave more room for useful output.
6Why Tokens Drive Cost and Speed
Most language model services charge by the token, counting both what you send and what you receive. This means a verbose prompt or a long response literally costs more, and optimizing token usage is a direct way to control expenses. Trimming redundant instructions and unnecessary context adds up across many calls.
Speed is also tied to tokens because the model generates one token at a time. Longer outputs take proportionally longer to produce, and very long inputs take time to process before generation even begins. Latency-sensitive applications benefit from keeping both input and output lean.
Understanding this token economy changes how you design applications. You start to see prompts as having a budget, retrieval as a tradeoff between context and cost, and output length as something worth constraining. Small per-call savings compound into large differences at scale.
7Why Models Struggle to Count Letters
A famous quirk is that language models often miscount the letters in a word or fail simple spelling tasks. This makes more sense once you know about tokenization: the model sees a word as one or a few tokens, not as a sequence of individual letters, so the internal letters are not directly visible to it.
Asking how many times a particular letter appears in a word requires reasoning about characters the model does not natively perceive. It has learned some spelling indirectly from training, but the information is not laid out for it the way it is for a human reading letter by letter.
This explains a whole class of surprising failures on tasks that seem trivial. It is not that the model is unintelligent; it is that the unit it operates on hides the very detail the task depends on. Recognizing this helps you avoid asking models to do things their input representation makes hard.
8Tokenization of Code and Other Languages
Tokenizers are usually optimized for the text they were trained on, which is heavily weighted toward common languages, especially English. Text in less-represented languages often breaks into many more tokens, sometimes down to individual characters, which means the same message costs more and fills the context window faster.
Code has its own tokenization behavior, where indentation, symbols, and identifiers can tokenize in ways that seem inefficient. Long variable names, unusual symbols, and dense formatting can consume tokens quickly, which is one reason working with large codebases stresses context limits.
This uneven efficiency has real fairness and cost implications, since users writing in some languages effectively pay more and hit limits sooner for equivalent content. Being aware of it helps you set expectations and design around the tokenizer's blind spots.
9Practical Implications for Builders
Knowing how tokenization works changes concrete decisions. You measure prompt and document sizes in tokens rather than characters, you chunk long texts at token boundaries that keep meaning intact, and you budget context deliberately across instructions, retrieved content, and expected output.
It also informs prompt design. Because whitespace and formatting affect tokenization, small changes in how you structure a prompt can shift token counts. For high-volume applications, trimming boilerplate and keeping instructions tight yields real savings without hurting quality.
Most providers offer tools to count tokens for a given piece of text, and using them removes guesswork. Checking token counts before you deploy prevents surprises around cost, latency, and context overflow that would otherwise appear only in production.
10Special Tokens and Structure
Beyond ordinary text, tokenizers include special tokens that mark structure, such as the start and end of a message, boundaries between a system and a user turn, or the end of the generation. These tokens are how the model knows where roles begin and end in a chat conversation.
These structural tokens are usually inserted automatically by the interface you use, but they still consume part of your context budget. In chat applications, each message carries some overhead of special tokens on top of its visible content, which adds up over long conversations.
Understanding that structure itself is tokenized clarifies why conversation formatting matters and why the model responds to role boundaries. It is all tokens to the model, including the invisible scaffolding that organizes a dialogue.
11The Bigger Picture
Tokenization is a humble but foundational layer that shapes almost everything about how language models behave in practice. It sits between the human world of words and the model's world of numbers, and its design choices ripple out into cost, capability, and quirks.
Researchers continue to explore alternatives, including approaches that operate closer to raw bytes or characters, aiming to reduce some of tokenization's downsides. For now, sub-word tokens remain the standard, so understanding them is essential for anyone building with these models.
Grasping tokenization gives you an unusually high return on a small investment of learning. Many things that seem mysterious about language models become obvious once you see the world the way the model does, one token at a time.
12Tokens, Boundaries, and Robustness
Because a model sees only a flat stream of tokens, it does not inherently distinguish your trusted instructions from text that arrived inside a document or user message. Everything becomes tokens in one sequence, which is why carefully separating instructions from untrusted content matters when you build applications. The model treats them as the same kind of input unless you design around it.
This flat view also explains why formatting choices influence behavior. Clear delimiters, consistent structure, and explicit labels help the model tell sections apart, since those cues are themselves tokens that signal boundaries. Well-structured prompts are not just tidy; they change how reliably the model interprets your intent.
Being mindful of how content is tokenized and combined leads to more robust systems. You place trusted instructions where they carry weight, mark untrusted input clearly, and avoid assuming the model perceives a boundary you did not make explicit. Designing with the token stream in mind is quietly one of the most practical safeguards you can adopt.
13Practice on SkillVeris
The concept clicks fastest when you experiment. Run some text through a tokenizer, watch how words split into pieces, compare English with code or another language, and see how token counts differ from word counts. These small experiments turn an abstract idea into something you can feel.
Carry the token mindset into your projects: budget context deliberately, measure sizes in tokens, and design prompts with the tokenizer's behavior in mind. These habits directly improve the cost, speed, and reliability of what you build.
On SkillVeris you can work through hands-on lessons that connect tokenization to real prompting, context management, and cost control, so you learn not just what tokens are but how to build smarter with them. Try it on your own text and let the results teach you.
Related Reading
Get The Print Version
Download a PDF of this article for offline reading.
About the Publisher
SkillVeris Team
AI Research Team
Our AI team covers the latest in machine learning, generative AI, and emerging tech — clearly and accurately.
View all postsRelated Posts
Never miss an update
Get the latest tutorials and guides delivered to your inbox.
No spam. Unsubscribe anytime.