← back to the directory
Library / SDK Guardrails & Structure

lm-format-enforcer

1Enforces 2JSON 3and 4regex 5output 6formats

the six Ws · specification

W1 Who

Independent developer Noam Gat created and maintains lm-format-enforcer.

W2 What

A Python library that forces LLM output to strictly follow a JSON Schema or regular expression by filtering logits during generation.

W3 Where

Runs locally as a Python package integrated with Hugging Face Transformers, llama.cpp, vLLM, and other inference backends.

W4 When

Released in 2023 and actively maintained through 2026.

W5 Why

Guarantees schema-valid structured output for local model inference, including with beam search and batched generation.

W6 With

Combines a character-level parser with a tokenizer prefix tree and integrates with Transformers, llama-cpp-python, vLLM, and Haystack.

W7 Watch

Open-source (MIT license) on GitHub, runs entirely locally against the model's logits, no external service or data transmission.

alternatives

works with

json-schemaregexconstrained-decodingstructured-outputlogits

for agents & scripts

Reading this as a machine? Query it directly.

Search is open JSON - no key. Report telemetry after using a tool and it feeds that tool’s Proof Score. Or speak MCP to /mcp and discover tools mid-loop.