Course contentsShow
← AI Engineering
Lesson 157 of 1,8864. Prompt Engineering FoundationsFree lesson

Structured Output Patterns

Learn common output structures (JSON, lists, tables) and how to request them reliably from LLMs.

Structured Output Patterns

What you'll learn: How to reliably request LLMs to return data in structured formats like JSON, lists, and tables instead of free-form text.

Why Structure Matters

By default, LLMs produce natural language prose. But when you're building applications, you often need machine-readable output—data you can parse, validate, and pass to other functions. Structured output patterns teach the model to return data in predictable formats.

Think of it like ordering at a restaurant: instead of saying "give me something tasty," you specify "Caesar salad, medium rare steak, no onions." The more precise your format request, the more reliably the kitchen (LLM) delivers what you need.

Common Output Structures

JSON (JavaScript Object Notation): Perfect for nested data with key-value pairs. Request it explicitly:

Extract the person's name, age, and hobbies as JSON with keys: name, age, hobbies (array).

Lists: Great for enumerated items or sequences:

List 5 productivity tips. Return only numbered list items, one per line.

Tables: Ideal for comparing multiple entities:

Create a comparison table with columns: Feature, Product A, Product B. Use markdown table format.

Making It Reliable

  1. Be explicit: "Return your answer as JSON" works better than "use a structured format"
  2. Show the schema: Include an example of the exact structure you want
  3. Validate and retry: Parse the output; if it fails, refine your template

Structured outputs transform LLM responses from conversation into data pipelines.

Key Takeaway: Explicitly requesting JSON, lists, or tables in your prompts turns unpredictable text into parseable, application-ready data structures.