← Back to Notes

What Is a Token, Really?

Tokens are the model-specific pieces that turn text into numbers. They are not fixed words, and their boundaries shape context limits, cost, and speed.

Type a sentence into an AI chat box and it looks as if the model receives the same words you wrote.

It does not.

Before a language model works with text, a tokenizer breaks that text into pieces called tokens. Those pieces are mapped to numbers. The model processes the numbered sequence and predicts which token should come next.

A token can be a whole word. It can also be part of a word, a punctuation mark, or a space attached to the text after it. That is why “one token equals one word” is a tempting shortcut—and a wrong mental model.

The useful definition is simpler:

A text token is one item from a model's tokenizer vocabulary.

The exact items depend on the tokenizer used with that model.

A Sentence Does Not Always Split at the Spaces

OpenAI's official tiktoken guide gives this example for its cl100k_base encoding:

tiktoken is great!

It becomes six pieces:

t · ikt · oken · is · great · !

Notice what happened. The unfamiliar-looking word tiktoken was divided into three subword pieces. The spaces before is and great became part of those tokens. The exclamation point became its own token.

Colored tokenization diagram of the sentence 'tiktoken is great!' split by OpenAI's cl100k_base encoding into six pieces: t, ikt, oken, a leading space plus is, a leading space plus great, and an exclamation point, with token IDs 83, 8251, 2488, 382, 2212, and 0 below the pieces.
One verified split using OpenAI's cl100k_base encoding. Another model or encoding may divide the same sentence differently.

Each piece also has an integer ID. In this encoding, the six IDs are 83, 8251, 2488, 382, 2212, and 0. The model does not attach meaning to the number 8251 as humans do. The ID is an index the system uses to look up a learned numerical representation.

The IDs are not universal labels. The same text can map to different pieces and different IDs under a different tokenizer.

Why Break Text into Odd-Looking Pieces?

A model could treat every character as a separate unit. It could also try to keep every possible word intact. Both approaches create problems.

Character-by-character text makes sequences long. A word-only vocabulary becomes enormous and still struggles with new names, misspellings, technical terms, and languages that build complex words differently.

Most modern text tokenizers use units somewhere between characters and words. Common patterns can remain together. Less familiar text can be assembled from smaller pieces.

Hugging Face's official tokenization overview describes three major subword approaches—BPE, Unigram, and WordPiece. Their details differ, but the practical idea is shared: keep a manageable vocabulary while retaining a way to represent text the tokenizer has not stored as one familiar unit.

That is why a common word may fit into one token while an unusual surname, product name, URL, or variable name takes several.

Spaces and Punctuation Count Too

Humans tend to see spaces as empty separators. A tokenizer does not have to treat them that way.

In many English examples, a leading space is grouped with the word that follows it. That means great at the start of a line and great after another word may not be represented by the same token.

Punctuation can stand alone or join a nearby pattern. Contractions, quotation marks, emoji, line breaks, indentation, and repeated symbols can all affect the split.

This matters when working with code. Code contains syntax that ordinary prose rarely uses: braces, operators, indentation, long identifiers, and paths. A short-looking code sample can therefore have a token count that is not obvious from its word count.

Languages Do Not Pay the Same Token Cost

The familiar heuristic that one token is about four English characters—or roughly three quarters of an English word—comes from OpenAI's guidance. It is a rough planning estimate, not a conversion formula.

Token efficiency depends on the language, script, text, and tokenizer vocabulary. A tokenizer trained with better coverage of a language may represent its text in fewer pieces than an older or differently trained tokenizer. Another language may require more tokens for an idea that takes fewer tokens in English.

Do not estimate multilingual capacity or cost by counting English words. Use the tokenizer or counting endpoint for the actual model and actual text.

The Same Text Can Split Differently by Model

There is no single “AI tokenizer.”

Providers use different algorithms and vocabularies. A provider can also use different encodings for different model families. OpenAI's guide, for example, lists separate encodings associated with different generations of GPT models and demonstrates that they divide some words, arithmetic, and Japanese text differently.

So a colored tokenizer screenshot should always identify the encoding or model it represents. It is evidence for that configuration, not a universal map of the sentence.

If an exact count matters:

  1. identify the exact model or API endpoint;
  2. use the tokenizer library or token-counting endpoint recommended by its provider;
  3. include the full structured request when possible, not only the visible prose;
  4. check actual usage returned by the API after the request.

The third step matters because a request may include system instructions, conversation history, tool definitions, documents, or formatting added by the application. Anthropic's official token-counting documentation, for example, accepts structured messages, tools, images, and PDFs, and notes that its preflight count is an estimate that may differ slightly from actual usage.

Why Token Counts Matter

Tokens are not just an implementation detail. They affect three things people notice.

Context limits

A model's context window is the amount of material it can work with in one request or turn, measured in tokens. The budget can include instructions, messages, retrieved documents, tool definitions and results, and room for the response.

Illustrative context-budget bar divided into system instructions, conversation, retrieved sources, tool results, and room for the model's answer, showing that all parts share limited capacity and more input leaves less room for output.
A conceptual context budget. The proportions are illustrative; actual limits and accounting rules vary by model and API.

If the input occupies more of the available budget, less may remain for the output. Some APIs enforce separate output caps as well. The exact accounting is product-specific, but the shared principle is durable: tokens consume finite working capacity.

Capacity is only half of the problem. Even when everything fits, irrelevant material can make the useful signal harder to use. That is the focus of Why More Context Can Make an AI Agent Worse.

Cost

Many model APIs charge by input and output tokens, sometimes with different rates for cached input, generated output, or internal reasoning. More words often mean more tokens, but the relationship is not fixed enough for a word counter to replace provider usage data.

Latency

More input has to be processed, and more output has to be generated. Hardware, model architecture, caching, service load, and provider implementation all affect speed, so token count is not a stopwatch. It is still one meaningful part of the workload.

Text Is Not the Whole Multimodal Story

Images and audio are not usually passed through the same text-tokenizer path as a sentence. Multimodal systems encode or meter them using modality-specific methods.

An API may still report their usage in tokens or token-like units so the service can apply context limits and billing. That does not mean a photograph was chopped into word fragments. It means the product exposes a common accounting unit around several kinds of model input.

The distinction is useful: this article's colored chunks explain text tokenization. Multimodal usage accounting is broader.

A Better Way to Think About Tokens

A token is not a word, character, syllable, or fixed amount of meaning.

It is a model-specific unit in a tokenizer's vocabulary, represented by an ID and processed as part of a sequence.

That definition explains the behavior that otherwise feels arbitrary:

  • common text may stay whole;
  • unfamiliar names may split into several pieces;
  • spaces and punctuation can consume tokens;
  • code and different languages can produce surprising counts;
  • the same sentence can split differently for another model;
  • input and output compete for a finite context budget.

Use rough heuristics for rough planning. When limits, cost, or reproducibility matter, count with the tool made for the exact model.

The colored blocks are not how the model “sees words.” They are the pieces its surrounding system chose so text could become numbers—and numbers could become the next prediction.