Press ESC to exit fullscreen
📖 Lesson ⏱️ 75 minutes

Output Format Control

Get structured JSON, markdown, tables, and code reliably from LLMs

Why Output Format Matters

Without format instructions, LLMs produce inconsistent output. Sometimes JSON, sometimes prose, sometimes a mix. For downstream processing, you need reliability.

Getting JSON

Be explicit about the schema:

Extract the key information from this job posting. Return ONLY valid JSON — no explanation, no markdown wrapper.

Schema:
{
  "title": "string",
  "company": "string",
  "salary_min": "number or null",
  "salary_max": "number or null",
  "remote": "boolean",
  "required_skills": ["string"]
}

Posting: [TEXT]

Getting Markdown

Write a comparison of PostgreSQL vs MongoDB for a high-traffic API backend.
Format as a markdown document with:
- An H2 heading for each database
- A "Best for" subsection under each
- A final "Recommendation" section

Getting Tables

Compare the top 3 JavaScript frameworks (React, Vue, Svelte) across these dimensions: 
learning curve, performance, ecosystem size, and best use case.
Return as a markdown table.

Getting Code

Write a Python function that parses a CSV file and returns a list of dicts.
Requirements:
- Type hints
- Handle missing values by replacing with None
- Single docstring line
- No external libraries

Reinforcement Trick

Repeat format instructions at the end:

[Main instruction here]

Remember: respond ONLY with valid JSON. No prose, no explanation.