#8686th of 109 in Model serving
xgrammar
Constrained-decoding library for JSON, regex and grammar-guided LLM output
- Stars
- 2k
- License
- Apache-2.0
- Last commit
- Nov 2026
- Last release
- Nov 2026
- Language
- Python
1,629 on 28 Apr 20262,028 on 24 Nov 2026
From GitHub's daily star counts.
Checked on GitHub.
Overview
XGrammar is a library that constrains LLM token generation so output follows a JSON schema, regex or custom context-free grammar. It is used as a structured-output backend in inference engines such as vLLM, SGLang, TensorRT-LLM and MLC-LLM. It installs from PyPI and has Python, C++, JavaScript and Swift APIs.
Who it is for: Engineers building or extending LLM inference engines with structured output
Strengths
- Supports JSON, regex and general context-free grammars in one engine
- Integrated into vLLM, SGLang, TensorRT-LLM, MLC-LLM, OpenVINO GenAI and Modular MAX
- APIs in Python, C++, JavaScript and Swift; runs on Linux, macOS and Windows
- Hardware coverage includes CPU, NVIDIA, AMD, Apple Silicon and TPU
Weaknesses
- Library only: no model server or HTTP API of its own
- Needs an inference engine or tokenizer integration to be useful
- Rust support is a community binding, not part of this repo
- Near-zero overhead claim is given without figures in the README
What it needs
- GPU optional
- Models: Qwen, Llama, DeepSeek, Phi, Gemma
What changed
From the release notes. No flag means the note does not say so, not that the upgrade is safe.
Known problems
Open now, reported in the last 90 days
- [Bug] JSON-schema chained bounded repeats compile ~60x slower since 0.2.6 ↗ (opens in a new tab)1 reactions
Reported, then fixed by a linked change
- Unable to match unicode chars ↗ (opens in a new tab)3 reactions · closed 3 Jan 2026Fixed by [Core] Fix UTF-8 support in positive character classes ↗ (opens in a new tab)
- [Bug] Build failure on ppc64le with GCC 14: false positive -Wfree-nonheap-object warning ↗ (opens in a new tab)1 reactions · closed 3 Jan 2026Fixed by cmake: Fix ppc64le build with GCC 14 false positive warning ↗ (opens in a new tab)
- [Bug] examples/benchmark/bench_grammar_compile_mask_gen.py fails on every case: allocate_token_bitmask(worker.vocab_size) cannot succeed, script ends in ZeroDivisionError ↗ (opens in a new tab)0 reactions · closed 8 Oct 2026Fixed by fix: fix the benchmark script ↗ (opens in a new tab)
- [Bug] separators=(",", ":") ignored for commas in json schema when any_whitespace=False ↗ (opens in a new tab)0 reactions · closed 8 Oct 2026Fixed by fix: preserve separators in generic JSON rules ↗ (opens in a new tab)
- [Bug] JSON Schema $ref fails when JSON Pointer traverses an anyOf array index ↗ (opens in a new tab)0 reactions · closed 6 Oct 2026Fixed by fix: resolve JSON Schema references through array indices ↗ (opens in a new tab)
Titles are the reporters' own words, taken from the project's GitHub issues and ranked by reactions. We have not tried to reproduce any of them.
Also in Model serving
See all 109| Rank | Project | Score |
|---|---|---|
| #84 | ik_llama.cppllama.cpp fork with faster CPU inference and extra quantization types | 58 out of 100 |
| #85 | litservePython framework for writing custom inference servers on FastAPI | 57 out of 100 |
| #87 | lightllmPython LLM inference server with token-level KV cache management | 56 out of 100 |
| #88 | luceboxInference server for AMD R9700 and Ryzen AI MAX+ with speculative decoding | 56 out of 100 |
| #89 | hyperqwenPatched vLLM setup serving Qwen3.8-27B fast on a single 24 GB GPU | 56 out of 100 |