Structured output

Also called JSON mode, structured outputs, json output

Getting an AI to answer in a fixed format, like JSON or a table, that software or people can use directly.

Structured output means the model's response follows a defined format rather than free-form prose. At the simple end, that is asking for a table, a numbered list or specific headings. At the strict end, it is valid JSON matching a schema, so code can parse it reliably without cleanup.

Most major APIs now offer a structured output or JSON mode. You provide a JSON schema, and the provider constrains generation so the output is guaranteed to match it: every required field present, correct types, nothing extra. This is far more reliable than asking nicely in the prompt, which usually works but occasionally adds a friendly sentence before the JSON or misses a bracket.

For people rather than programs, structure still helps. Tables make comparisons scannable, consistent headings make reports comparable week to week, and fixed fields make outputs easy to paste into spreadsheets. A good format describes what goes in each part, not just its shape: what to write when information is missing, which units to use and how long each field should be.

Example

An invoice processing tool asks for {"vendor": string, "total": number, "due_date": "YYYY-MM-DD", "po_number": string or null}. Using the API's structured output feature, every response parses, and missing purchase order numbers come back as null instead of "N/A" or "unknown".

Common mistake

Treating a valid format as a correct answer. Structured output guarantees the shape, not the truth: a perfectly valid JSON object can still contain a wrong total. Validate important values, and tell the model to use null rather than guessing when information is missing.

Find a prompt for the task in front of you.

96 prompts in 8 categories. Copy one, fill in the blanks, paste it into any model.

Browse prompts

Promptlexity is a free library of 96 AI prompts and 8 downloadable AI skills across 8 categories, plus a glossary of 64 AI and prompting terms. Each prompt shows the exact text to paste, the variables to fill in, an example of what comes back, and why it works. Each glossary term has a plain-English definition, an example and a common mistake. 6 step-by-step guides cover the basics. No signup, works with ChatGPT, Claude, Gemini and other models.

Press Esc to close