Skip to content

Output Formatting

Platforms: claude openai gemini m365-copilot

Output formatting means telling the model exactly how to structure its response — whether that’s a table, JSON, bullet list, specific sections, or a template you define. Instead of hoping the model picks a useful format, you specify it upfront. This makes outputs immediately usable without manual reformatting.

LLMs (large language models) are very good at following structural instructions because they’ve seen millions of formatted documents during training. Specifying format reduces ambiguity about what “a good response” looks like, and makes outputs immediately usable in downstream workflows. However, note that format restrictions can sometimes degrade reasoning performance — Tam et al. (2024) found a tradeoff between structure and thinking quality. For complex analysis, consider letting the model reason freely first, then reformatting.

  • Output needs to feed into another system (JSON, CSV, XML)
  • Reports or analyses that need consistent structure across runs
  • Comparing multiple items side-by-side (tables)
  • When you’ll reuse the same prompt and need predictable output
  • When output will be parsed programmatically
{Task description}
Format your response as:
{Format specification — template, example structure, or explicit format name}

Filled-in example:

Summarize the three main risks of migrating our database from MySQL to PostgreSQL.
Format your response as a markdown table with these columns:
| Risk | Likelihood (High/Med/Low) | Impact | Mitigation |

Context: You need to compare tools and want a scannable side-by-side view.

Compare the following 4 project management tools on these dimensions: price, team size
limit, integrations, and learning curve. Tools: Asana, Linear, Monday.com, Notion.
Present as a markdown table with tools as columns and dimensions as rows.

Why this works: Tables make comparisons scannable, and specifying rows vs. columns removes ambiguity about the layout.

Context: You’re extracting structured data from unstructured text for use in an application.

Extract the following fields from this job posting: title, company, location,
salary_range, required_skills (as an array), experience_years.
Return as valid JSON with no additional text or explanation.
Job posting:
[paste job posting text here]

Why this works: The schema is fully specified — field names, types (array for skills), and the instruction to return only JSON ensures clean, parseable output.

Context: You want a consistent format for a recurring report.

Write a weekly status update following this exact structure:
## Completed This Week
- [bullet items]
## In Progress
- [bullet items with % complete]
## Blocked
- [bullet items with blocker description]
## Next Week
- [planned items]
Here's what happened this week: shipped the auth module, 60% done with the dashboard
redesign, waiting on API credentials from the vendor, and next week we start load testing.

Why this works: The exact template is provided, so the model fills in the structure rather than inventing its own — ensuring consistency across weeks.

  • Tam et al. 2024 — Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performancearxiv.org/abs/2408.02442
  • Liu et al. 2024 — “We Need Structured Output”: Towards User-centered Constraints on LLM Outputarxiv.org/abs/2404.07362