{
 "kind": "tool",
 "slug": "xgrammar",
 "path": "tools/xgrammar/",
 "name": "xgrammar",
 "maker": null,
 "density": "basic",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Prompts, structured output and evals",
   "tools/llm-tooling/"
  ]
 ],
 "lead": "Structured generation library - enables efficient constrained decoding for LLM outputs.",
 "chips": [
  {
   "label": "Prompts, structured output and evals",
   "path": "tools/llm-tooling/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install xgrammar"
 },
 "links": [
  {
   "label": "Website",
   "href": "https://xgrammar.mlc.ai/"
  }
 ],
 "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://xgrammar.mlc.ai/"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Not checked yet",
   "status": "unknown",
   "sub": null,
   "note": "",
   "src": "https://xgrammar.mlc.ai/"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "1 projects",
   "status": "info",
   "sub": "#44 of 78 in its category",
   "note": "Dependency in 1 public GitHub projects set up for AI coding agents that we scanned (0.0%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What xgrammar does",
   "parts": [
    {
     "t": "prose",
     "text": "Structured generation library - enables efficient constrained decoding for LLM outputs."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "xgrammar popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "48",
       "of": "/ 100",
       "l": "Gid Score, #2242 overall"
      },
      {
       "n": "1.6M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "1",
       "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 xgrammar is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "xgrammar is a dependency in 1 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 25 projects, and what it is used with below comes from all of them.",
      "The most used alternative in our scan is Instructor (4 projects).",
      "Projects that use it most often also use aiohttp (100.0%), AnyIO (100.0%), attrs (100.0%)."
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 100.0% of its projects",
       "v": "aiohttp",
       "path": "tools/aiohttp/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "AnyIO",
       "path": "tools/anyio/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "attrs",
       "path": "tools/attrs/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "charset-normalizer",
       "path": "tools/charset-normalizer/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "Click",
       "path": "tools/click-py/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "dill",
       "path": "tools/dill/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about xgrammar",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "More in Prompts, structured output and evals",
       "path": "tools/llm-tooling/",
       "items": [
        {
         "text": "Ultracite",
         "path": "tools/ultracite/"
        },
        {
         "text": "tiktoken (Python)",
         "path": "tools/tiktoken-pypi/"
        },
        {
         "text": "tokenizers",
         "path": "tools/tokenizers/"
        },
        {
         "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/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "xgrammar",
       "me": true,
       "facts": [
        "Apache-2.0",
        "Gid 48",
        "1.6M/wk"
       ]
      },
      {
       "name": "Instructor",
       "why": "Python library to get structured outputs from language models with validation and parsing.",
       "path": "tools/instructor/",
       "facts": [
        "MIT",
        "Gid 63",
        "2.6M/wk"
       ]
      }
     ],
     "more": "Compare xgrammar with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install xgrammar"
    },
    {
     "t": "gap",
     "text": "No step-by-step start for xgrammar yet: we have not written its hand-checked card."
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi xgrammar"
  ],
  [
   "Category",
   "Prompts, structured output and evals"
  ],
  [
   "License",
   "Apache-2.0"
  ],
  [
   "Gid Score",
   "47.8"
  ],
  [
   "Rank in category",
   "#44 of 78"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": null
}