mlc-ai/xgrammar
A C++ library enabling fast, portable constrained decoding and structured JSON/regex generation for large language models.

Velocity · 7d
+2.4
★ / day
Trend
→steady
star history
XGrammar is a structured generation library designed for efficient and flexible constrained decoding during LLM inference. It enables models to produce valid JSON, regex-constrained, or user-defined structured outputs by constraining the token selection space at each generation step. The library is implemented in C++ with bindings for Python and integrates natively into popular inference runtimes like vLLM, TensorRT-LLM, and Modular MAX.