{
 "kind": "tool",
 "slug": "tokenizers",
 "path": "tools/tokenizers/",
 "name": "tokenizers",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Prompts, structured output and evals",
   "tools/llm-tooling/"
  ]
 ],
 "lead": "Fast NLP tokenizer library by Hugging Face for text processing.",
 "chips": [
  {
   "label": "Prompts, structured output and evals",
   "path": "tools/llm-tooling/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install tokenizers"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/huggingface/tokenizers"
  },
  {
   "label": "Website",
   "href": "https://github.com/huggingface/tokenizers"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Apache-2.0",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI classifier.",
   "src": "https://github.com/huggingface/tokenizers"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 23, 2026",
   "note": "Latest GitHub release Oct 9, 2026. ",
   "src": "https://github.com/huggingface/tokenizers"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "25 projects",
   "status": "info",
   "sub": "#3 of 78 in its category",
   "note": "Dependency in 25 public GitHub projects set up for AI coding agents that we scanned (0.4%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://huggingface.co/docs/tokenizers/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What tokenizers does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "tokenizers popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "77",
       "of": "/ 100",
       "l": "Gid Score, #167 overall"
      },
      {
       "n": "55.6M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "11.3K",
       "l": "GitHub stars"
      },
      {
       "n": "25",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How tokenizers is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "17 projects, 0.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "14 projects, 0.5%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "13 projects, 0.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 100.0% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      },
      {
       "l": "In 92.0% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      },
      {
       "l": "In 88.0% of its projects",
       "v": "Hugging Face Hub",
       "path": "tools/huggingface-hub/"
      },
      {
       "l": "In 84.0% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 84.0% of its projects",
       "v": "tqdm",
       "path": "tools/tqdm/"
      },
      {
       "l": "In 80.0% of its projects",
       "v": "charset-normalizer",
       "path": "tools/charset-normalizer/"
      },
      {
       "l": "In 80.0% of its projects",
       "v": "fsspec",
       "path": "tools/fsspec/"
      },
      {
       "l": "In 80.0% of its projects",
       "v": "packaging",
       "path": "tools/packaging/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "tokenizers in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Serving builds leave training out",
       "v": "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."
      },
      {
       "l": "Old tokenizer.json files still load",
       "v": "<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."
      },
      {
       "l": "Correct on CPUs without SIMD",
       "v": "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."
      },
      {
       "l": "Byte-exact pre-tokenizer grammars",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The v1 release candidate is missing features",
       "v": "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."
      },
      {
       "l": "Breaking changes in the move to 1.0",
       "v": "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>."
      },
      {
       "l": "Known load failure for some models",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Load a pretrained tokenizer, encode and decode"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Python",
       "code": ">>> from tokenizers import Tokenizer\n>>> tokenizer = Tokenizer.from_pretrained(\"meta-llama/Llama-3.1-8B\") # or .from_file(path)\n>>> tokenizer.encode(\"Hello, y'all! How are you 😁 ?\")\nEncoding(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])\n>>> tokenizer.tokenize(\"Hello\")\n['<|begin_of_text|>', 'Hello']\n>>> tokenizer.decode([15339, 1917])\n'hello world'\n>>> tokenizer.decode_tokens(tokenizer.encode(\"Hello\"))\n['<|begin_of_text|>', 'Hello']"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about tokenizers",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "numpy: Arrays",
        "pyyaml: YAML parsing",
        "huggingface-hub: Hub downloads",
        "pydantic: Data validation",
        "tqdm: Progress bars",
        "charset-normalizer: Encoding detection"
       ]
      },
      {
       "title": "More in Prompts, structured output and evals",
       "path": "tools/llm-tooling/",
       "items": [
        {
         "text": "Ultracite",
         "path": "tools/ultracite/"
        },
        {
         "text": "LangSmith",
         "path": "tools/langsmith-pypi/"
        },
        {
         "text": "GPT Tokenizer",
         "path": "tools/gpt-tokenizer/"
        },
        {
         "text": "Langfuse (Python)",
         "path": "tools/langfuse-pypi/"
        },
        {
         "text": "TokenLens",
         "path": "tools/tokenlens/"
        },
        {
         "text": "@graphql-codegen/typescript-operations",
         "path": "tools/graphql-codegen-typescript-operations/"
        },
        {
         "text": "tiktoken (JavaScript)",
         "path": "tools/tiktoken-npm/"
        },
        {
         "text": "partial-json",
         "path": "tools/partial-json/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "tokenizers",
       "me": true,
       "facts": [
        "Apache-2.0",
        "Gid 77",
        "55.6M/wk"
       ]
      },
      {
       "name": "tiktoken (Python)",
       "why": "Fast BPE tokenizer for OpenAI models enabling accurate token counting and text splitting.",
       "path": "tools/tiktoken-pypi/",
       "facts": [
        "MIT",
        "Gid 81",
        "56.1M/wk"
       ]
      },
      {
       "name": "SentencePiece",
       "why": "Unsupervised text tokenizer and detokenizer from Google for natural language processing.",
       "path": "tools/sentencepiece/",
       "facts": [
        "Apache-2.0",
        "Gid 65",
        "7.2M/wk"
       ]
      }
     ],
     "more": "Compare tokenizers with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install tokenizers"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## tokenizers\n- 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`.\n- Load tokenizers with `Tokenizer.from_pretrained(\"<repo>\")` or `Tokenizer.from_file(path)`. Read ids from the returned `Encoding`.\n- 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.\n- If `huggingface_hub` v2 is in the environment, use tokenizers v0.23.3 or later. That release loosened the requirement.\n- In Rust, depend on the umbrella `tokenizers` crate unless you know you want less.\n- For wasm32 builds, enable the `simd128` target feature. Without it, the scalar path is used.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi tokenizers"
  ],
  [
   "Category",
   "Prompts, structured output and evals"
  ],
  [
   "License",
   "Apache-2.0"
  ],
  [
   "Latest version",
   "v0.23.3, October 9, 2026"
  ],
  [
   "On GitHub since",
   "November 2019"
  ],
  [
   "Gid Score",
   "76.7"
  ],
  [
   "Rank in category",
   "#3 of 78"
  ],
  [
   "GitHub",
   "huggingface/tokenizers"
  ],
  [
   "Last change",
   "Nov 23, 2026"
  ]
 ],
 "good": [
  "Used by Transformers, as listed by the source; we have not checked each one."
 ],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/huggingface.png"
}