---
title: "Structured Prompt"
slug: "structured-prompt"
category: "glossary"
tags: ["glossary", "ai-agents", "llm", "prompting", "output", "json"]
status: "stable"
last_updated: 2026-05-14
summary: "A structured prompt instructs an LLM to produce output in a machine-readable format such as JSON or XML, enabling reliable parsing without brittle regex."
related:
  [
    "[[glossary/structured-output]]",
    "[[glossary/system-message]]",
    "[[glossary/role-priming]]",
    "[[glossary/tool-call]]",
    "[[glossary/few-shot-prompting]]",
    "[[glossary/schema-validated]]",
  ]
---

## Overview

This page is the atomic definition. Prompt engineering patterns live at [[prompt-engineering/prompt-design]].

## 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 [[glossary/system-message]] (weakest, model may deviate); [[glossary/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 [[glossary/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 [[glossary/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

- [[glossary/structured-output]] - the broader term for LLM outputs with enforced schema.
- [[glossary/schema-validated]] - structured prompts are a method; schema validation confirms compliance.
- [[glossary/tool-call]] - the most reliable way to get structured output; the function signature is the schema.
- [[glossary/system-message]] - the typical location for schema instructions.
- [[glossary/few-shot-prompting]] - providing examples of the desired format is often more reliable than schema descriptions alone.

## Citing this term

> See [[glossary/structured-prompt|Structured Prompt]] (llmbestpractices.com/glossary/structured-prompt).

## Related

- [[glossary/structured-output]]
- [[glossary/system-message]]
- [[glossary/role-priming]]
- [[glossary/tool-call]]
- [[glossary/few-shot-prompting]]
- [[glossary/schema-validated]]
