prompt-eng
Glossary ↗Output Formatting
Output formatting refers to explicitly instructing an LLM about the exact shape, structure, and format its response should take — a numbered list, a markdown table, a specific JSON schema, a fixed-length summary, a particular tone — rather than letting the model choose its own presentation by default. This matters enormously for SaaS applications because raw LLM output is meant for human reading by default (models are trained to be helpful and conversational, often prefacing answers with "Sure! Here's..." or adding trailing caveats), which is exactly the wrong shape for a response that a downstream function needs to parse programmatically and insert into a database, a UI component, or another API call. Explicit output-formatting instructions close that gap. Effective techniques include: showing the exact target format via a few-shot example rather than describing it abstractly (models follow shown formats more reliably than described ones); using strong, unambiguous language ("Respond with ONLY the JSON object, no other text" rather than "please format as JSON"); specifying a strict schema with field names and types; and, for the most reliability, using a provider's dedicated structured-output feature (JSON mode or JSON schema-constrained generation) rather than relying on instructions alone, since instructions can occasionally be ignored or partially followed while a schema-constrained API call is mechanically guaranteed to produce valid JSON matching the schema. Beyond machine-readability, output formatting is also a UX lever — a well-formatted response (proper markdown tables, consistent heading structure, appropriately terse or detailed length) directly affects how usable and trustworthy an AI feature feels to end users, independent of whether the underlying content is technically correct. Concrete worked example: an AI meeting-notes SaaS tool initially prompts "Summarize this meeting transcript" and receives inconsistent, prose-paragraph output that's hard to render cleanly in the UI. The team rewrites the prompt with explicit output formatting: "Summarize the meeting transcript below into exactly this markdown structure, with no additional commentary before or after:\n\n## Key Decisions\n- [bullet per decision]\n\n## Action Items\n- [ ] [owner]: [task]\n\n## Open Questions\n- [bullet per question]" — the model now reliably returns parseable, consistently structured markdown that the frontend renders identically every time, rather than a paragraph the UI has to awkwardly wrap in a generic text block. For output that will be rendered directly (rather than parsed programmatically), it's also worth explicitly specifying negative formatting constraints alongside positive ones — "no preamble, no closing summary, no markdown headers above H2" — since models left to their own judgment tend toward a conversational default that reads naturally in a chat window but looks out of place embedded inside a styled UI component expecting a tighter, more purpose-built shape.
Related terms