Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d ยท Codex 0d For AI agents: Markdown Updated Nov 26, 2026

tokenizers

Fast NLP tokenizer library by Hugging Face for text processing.

Prompts, structured output and evalsPYPI

GitHubWebsite

1. License

License from PyPI classifier.

github.com/huggingface/tokenizers

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What tokenizers does

Hugging Face's tokenizer library is partway through a Rust-first rewrite to v1.0. Inference is split from training so a serving build carries only what it needs, and other projects treat its output as the correct answer for token ids.

tokenizers popularity

77 / 100
Gid Score, #167 overall
55.6M
downloads a week, pypi
11.3K
GitHub stars
25
agent projects use it
tokenizers: downloads per weekPyPI, tokenizers 54,756,773
tokenizers: GitHub starshuggingface/tokenizers 11,291

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How tokenizers is used

  • tokenizers is a dependency in 25 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.5% of the 1,623 Python ones), #3 of 78 in prompts, structured output and evals.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 756; those are left out of every share on this page.
  • The most used alternative in our scan is tiktoken (Python) (58 projects).
  • Projects that use it most often also use NumPy (100.0%), PyYAML (92.0%), Hugging Face Hub (88.0%).

By coding agent

17 projects, 0.5%
14 projects, 0.5%
13 projects, 0.5%

Often used with

In 100.0% of its projects
In 92.0% of its projects
In 88.0% of its projects
In 84.0% of its projects
In 84.0% of its projects
In 80.0% of its projects
In 80.0% of its projects
In 80.0% of its projects

tokenizers in practice

Strengths

Serving builds leave training out

Inference lives in <code>tk-encode</code> and training in <code>tk-train</code>. The README says the two have "opposite constraints", so a production binary does not link a trainer, a corpus reader or legacy converters.

Old tokenizer.json files still load

<code>tk-convert</code> rewrites tokenizer files from any older version into the canonical form. It is a pure JSON-to-JSON pass, and you can disable it to get smaller on-device builds.

Correct on CPUs without SIMD

Every vectorised kernel has a portable path that is always compiled. That path also serves as the test oracle for the vectorised versions, so missing CPU features only cost speed. On x86_64 the dispatch happens at runtime.

Byte-exact pre-tokenizer grammars

The <code>bitcannon</code> crate pre-tokenizes using a bitstream approach and has no runtime dependency on Unicode tables. It ships grammars for several current model families. The maintainers say it is, as far as they know, the fastest implementation for every pretokenizer regex on CPU.

Watch out for

The v1 release candidate is missing features

The docs say rc0 only loads a <code>tokenizer.json</code>, encodes and decodes. Building a tokenizer from components, editing it, saving it and training are not exposed yet.

Breaking changes in the move to 1.0

The maintainers say they introduced breaking changes in the switch from 0.23. They plan to describe them in a blog post that is not yet published. Installing the candidate needs <code>pip install --pre tokenizers</code>.

Known load failure for some models

The Rust core roadmap lists an open fix for ModernBERT and OLMo tokenizers, which fail to load with a "64-bit hash collision". Offset tracking and windowing are also still on the list.

Load a pretrained tokenizer, encode and decode

>>> from tokenizers import Tokenizer
>>> tokenizer = Tokenizer.from_pretrained("meta-llama/Llama-3.1-8B") # or .from_file(path)
>>> tokenizer.encode("Hello, y'all! How are you ๐Ÿ˜ ?")
Encoding(ids=[128000, 9906, 11, 379, 65948, 0, 2650, 527, 499, 27623, 223, 949], type_ids=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], attention_mask=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
>>> tokenizer.tokenize("Hello")
['<|begin_of_text|>', 'Hello']
>>> tokenizer.decode([15339, 1917])
'hello world'
>>> tokenizer.decode_tokens(tokenizer.encode("Hello"))
['<|begin_of_text|>', 'Hello']

More about tokenizers

Packages around it
  • numpy: Arrays
  • pyyaml: YAML parsing
  • huggingface-hub: Hub downloads
  • pydantic: Data validation
  • tqdm: Progress bars
  • charset-normalizer: Encoding detection
More in Prompts, structured output and evals

Alternatives

tokenizers This page

Apache-2.0Gid 7755.6M/wk

tiktoken (Python)

Fast BPE tokenizer for OpenAI models enabling accurate token counting and text splitting.

MITGid 8156.1M/wk

SentencePiece

Unsupervised text tokenizer and detokenizer from Google for natural language processing.

Apache-2.0Gid 657.2M/wk

Compare tokenizers with another tool

Get started

Install it.

pip install tokenizers

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## tokenizers
- Check whether the project pins the 0.23 line (latest release v0.23.3) or the v1 candidate. The candidate installs with `pip install --pre tokenizers`.
- Load tokenizers with `Tokenizer.from_pretrained("<repo>")` or `Tokenizer.from_file(path)`. Read ids from the returned `Encoding`.
- On v1 rc0, do not write code that trains, builds from components, edits or saves a tokenizer. The docs say these are not exposed yet.
- If `huggingface_hub` v2 is in the environment, use tokenizers v0.23.3 or later. That release loosened the requirement.
- In Rust, depend on the umbrella `tokenizers` crate unless you know you want less.
- For wasm32 builds, enable the `simd128` target feature. Without it, the scalar path is used.