JSON Mode (Structured Output)
A feature of AI APIs that constrains the model's output to valid JSON format, ensuring parseable, structured responses for programmatic use.
How It Works
The model is instructed (via API parameters or system prompt) to output only valid JSON. Some implementations use constrained decoding to guarantee syntactic validity by restricting which tokens can be generated at each step.
Use Cases
Data extraction (parse invoices, resumes, articles into structured fields), API responses, function calling arguments, database record creation, and any workflow requiring machine-readable LLM output.
Implementations
OpenAI's response_format: {type: 'json_object'}, Anthropic's tool use for structured output, and open-source tools like Instructor, Outlines, and LMQL for constrained generation.