# Tokenizer

> Canonical: https://skillalmanac.com/glossary/tokenizer | Last verified: 2026-11-24 | Index status: index-eligible

A tokenizer divides text into units called tokens. In many language-model pipelines, it also maps those units to vocabulary IDs. Token boundaries and counts depend on the tokenizer and its configuration.

Also called: tokenizers, AI tokenizer.

## In plain language

Before an AI model sees your message, a separate piece of software cuts the text into small chunks called tokens, and turns each chunk into a number. That software is the tokenizer. A common word may be one token, while a rare word, a name or a line of code may be cut into several. The reply is built from tokens too, and a second step turns them back into text. This matters for planning: limits and prices are counted in tokens, not words, and two models can count the same sentence differently because they can use different tokenizers or configurations. Tokenization transforms text into units and often IDs; that transformation is distinct from the model's subsequent prediction. For a count before sending a large prompt, use the provider's tool for the intended model and check whether it returns an estimate. Word-count rules of thumb can be inaccurate.

## Technical definition

Language-model tokenization commonly combines normalization, pre-tokenization, a segmentation model and post-processing, with an associated vocabulary mapping tokens to IDs. A fixed deployed configuration may be deterministic, while methods such as BPE-Dropout can sample different segmentations. Sennrich, Haddow and Birch studied subword encoding for rare and unknown words in translation. A vocabulary alone does not specify the whole tokenization procedure, and decoding need not restore text removed or changed by normalization.

## How it shows up when you use agents

Text selected for a model request is tokenized under that model's configuration. An agent may select, summarize or omit files and tool results; not every available file or result is necessarily sent in full. Other modalities and protocol overhead can also affect usage.

Counts and prices are separate. Model choice, input/output rates, caching and configuration can change cost. Anthropic documents a model-specific counting endpoint and calls its result an estimate. Recount for the intended model rather than applying a percentage rule across model generations.

## Worked example (illustrative)

Suppose one toy tokenizer represents a chosen string with two units and another uses three. These invented counts illustrate configuration dependence, not actual provider output. They do not determine a bill without the applicable pricing and usage rules.

## Common confusions

- **Tokenizer versus token.** The token is the unit, such as a word, part of a word or a byte. The tokenizer is the tool that cuts text into those units and maps them to numbers. See [Token](/glossary/token).
- **Tokenizer versus model.** The tokenizer has no knowledge and is not trained to answer questions. A language-model tokenizer prepares inputs for a compatible model. Its configuration can include normalization and segmentation choices, and some training tokenizers use stochastic segmentation.
- **Myth.** "A token is a word." Words are often split, and punctuation, spaces and code symbols count too, so word counts only roughly track token counts.
- **Myth.** "Same text, same count everywhere." Counts can differ with tokenizer configuration; use the counting guidance for the intended model.

## Worked examples in this catalogue

### [context-window-packer](https://skillalmanac.com/skills/skill-almanac/context-window-packer)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A record of which files were kept, shrunk or dropped to fit one prompt's token budget, and why.

Why it exercises the concept: The packing skill uses token estimates to plan a budget. Check selected input with the intended model’s counting tool; the plan is not an exact provider count.

### [agent-session-cost-review](https://skillalmanac.com/skills/skill-almanac/agent-session-cost-review)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A transcript-derived estimate of session token use, rather than an exact provider tokenizer count or billing record.

Why it exercises the concept: The report estimates usage from saved text. Model-specific counts, input/output rates, caching and configuration affect actual cost; compare estimates with provider usage records.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

```
/usage
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Claude Code's cost documentation says the Session block of this command shows the current session's token usage, with an estimated cost computed locally from token counts at list price unless an administrator has set a pricing table.

Why it exercises the concept: It is the place in a coding session where token counts, produced by the model's tokenizer, turn into a dollar figure you can act on.

## Related terms

- [Token](https://skillalmanac.com/glossary/token.md)
- [Context window](https://skillalmanac.com/glossary/context-window.md)
- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [Transformer](https://skillalmanac.com/glossary/transformer.md)
- [Inference](https://skillalmanac.com/glossary/inference.md)
- [Natural language processing (NLP)](https://skillalmanac.com/glossary/natural-language-processing.md)
- [Tokenization (NLP)](https://skillalmanac.com/glossary/tokenization.md)

## Sources

- [Neural Machine Translation of Rare Words with Subword Units](https://arxiv.org/abs/1508.07909), arXiv (Sennrich, Haddow and Birch) (accessed 2026-11-23)
- [Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting), Anthropic (Claude Docs) (accessed 2026-11-23)
- [Manage costs effectively](https://code.claude.com/docs/en/costs), Anthropic (Claude Code Docs) (accessed 2026-11-23)
- [The tokenization pipeline](https://huggingface.co/docs/tokenizers/pipeline), Hugging Face (accessed 2026-11-24)
- [BPE-Dropout: Simple and Effective Subword Regularization](https://aclanthology.org/2020.acl-main.170/), Provilkov et al. (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
