Skip to main content
← Back to techniques

Output formatting

Structure & output

Level 1 · Foundations

Specify the exact shape the response must take — JSON, a table, a fixed template — not just its content.

Output formatting prompts focus on constraining the shape of the response, not just its content: you provide an explicit schema or template (a JSON structure, a table with named columns, a fixed set of headings) and ask the model to fill it exactly. This matters whenever the output needs to be parsed by code or fit a rigid template, where a well-written but differently-shaped answer isn't actually usable.

When to use it

Use it whenever the output feeds into another system (parsing JSON, populating a database, filling a document template) or needs to match a house format exactly.

When to avoid it

Avoid it for open-ended creative or exploratory content where a rigid shape would work against the goal — a strict schema constrains phrasing and can flatten nuance you actually want.

Advantages

  • Makes the output reliably parseable/usable by downstream code or systems
  • Removes formatting inconsistency across multiple requests
  • Easy to combine with any other technique on this list

Disadvantages

  • Overly rigid formats can suppress useful nuance or edge cases in the content
  • The model can still occasionally deviate from the schema, especially with long outputs
  • Adds tokens to spell out the exact schema

Examples

Extract the key details from this job posting.

Input: [job posting text]

Respond only in the following format, with no extra text:
{
  "title": string,
  "location": string,
  "salary_range": string | null,
  "remote": boolean
}

Before returning the answer, verify that all required fields are present, types are correct, and no additional fields are included.
Advanced (JSON Schema Enforcement): Respond only with JSON matching exactly this JSON Schema, with no extra text:
{
  "type": "object",
  "properties": {
    "title": {"type": "string"},
    "salary_range": {"type": ["string", "null"]},
    "remote": {"type": "boolean"}
  },
  "required": ["title", "remote"],
  "additionalProperties": false
}

Advanced (Prefix Forcing, where the API/model supports specifying the start of its own response): begin your response with the literal character `{` and nothing before it.

Try it

Fill in the placeholders below and see the compiled prompt update live.

What you want to achieve.

The material to work from.

What the output should look like.

34
Words
234
Characters
0/3
Placeholders filled
1 min
Reading time
Quality score11
  • Completeness0
  • Clarity0
  • Context0
  • Specificity0
  • Constraints0
  • Format0
  • Output0
  • Constraints note0
  • Success criteria100
  • Scope focus100
  • Verification step0
  • Negative example0
  • Confidence0
  • Placeholder syntax100
  • Markdown structure0
Suggestions
  • Fill in the remaining placeholders.
  • Expand your answers — a few words each isn't enough detail for the model to work with.
  • Add background context so the model understands the situation.
{{OBJECTIVE}} Input: {{INPUT}} Respond only in the following format, with no extra text: {{OUTPUT}} Before returning the answer, verify that all required fields are present, types are correct, and no additional fields are included.
AI Assistant

Jump to a page…

Navigation