Overview
This page is the atomic definition. Prompt engineering patterns live at prompts.
Definition
A structured prompt is a prompt that constrains the model’s output to a defined schema, typically JSON or XML, so that the response can be parsed programmatically without brittle text extraction. There are several enforcement mechanisms: output schema instructions in the system-message (weakest, model may deviate); tool-call / function-calling (forces JSON-schema-compliant output as the tool argument); constrained decoding via grammar libraries such as Outlines or Guidance (forces token-by-token adherence to a grammar); and the Anthropic/OpenAI response_format: {type: "json_object"} parameter (encourages but does not guarantee valid JSON). The most reliable method is using the model’s native tool/function-calling interface with a declared JSON schema, which modern LLM APIs validate server-side. Structured prompts are essential for planner-executor pipelines where the executor must parse the planner’s output, for classification tasks that need a label plus confidence, and for data extraction tasks.
When it applies
Use structured prompts whenever downstream code will consume the LLM’s output programmatically. Avoid free-text output when a specific set of fields is needed; even small format deviations break parsers. Use schema-validated output when strict compliance is required.
Example
System message: “Respond only in JSON with fields: intent (string), confidence (float 0-1), entities (array of strings).”
User: “Book a flight to Paris on Friday.”
Response: {"intent": "book_flight", "confidence": 0.97, "entities": ["Paris", "Friday"]}.
Related concepts
- structured-output - the broader term for LLM outputs with enforced schema.
- schema-validated - structured prompts are a method; schema validation confirms compliance.
- tool-call - the most reliable way to get structured output; the function signature is the schema.
- system-message - the typical location for schema instructions.
- few-shot-prompting - providing examples of the desired format is often more reliable than schema descriptions alone.
Citing this term
See Structured Prompt (llmbestpractices.com/glossary/structured-prompt).