Advanced Prompt Engineering / Output Control & Format

Output Format Specification

Beginner [2/5]
Format definition Structure specification

Definition

Output format specification defines the exact structure of the desired response. By explicitly describing how the output should be formatted, you get consistent, predictable results that are easier to parse and process.

Format specification is critical for applications that need to programmatically consume LLM outputs.

Key Concepts

  • Structure definition: Specifying sections, order, and hierarchy
  • Format types: JSON, XML, Markdown, plain text, tables
  • Field requirements: Required vs optional fields
  • Example provision: Showing exactly what output should look like

Examples

Explicit Format
Detailed Structure
Output format: TITLE: [Article title] SUMMARY: [2-3 sentence summary] KEY_POINTS: - [Point 1] - [Point 2] - [Point 3] SENTIMENT: [positive/negative/neutral] CONFIDENCE: [high/medium/low]
Format by Example
Show Don't Tell
Respond in exactly this format: Product: iPhone 15 Pro Rating: 4.5/5 Pros: Great camera, Fast performance Cons: Expensive, Heavy Verdict: Recommended for power users Now review: [product to review]
Providing an example is often clearer than describing the format.

Interactive Exercise

Specify a Format

Create a format specification for movie reviews that includes:

- Movie title
- Rating (out of 10)
- Brief summary
- Recommendation (yes/no)

Pro Tips
  • Show an example output—it's clearer than describing
  • Use consistent delimiters (colons, brackets)
  • Specify data types for fields (number, string, boolean)
  • Consider using JSON for programmatic parsing

Related Terms