An output format instruction, also called a format specification, is the part of a prompt that tells a language model how to structure its response: which format to use, which fields to include, in what order, at what length and with what delimiters. In prompting for artificial intelligence systems, it separates what the model should say from how the answer must look.
Format instructions matter most when a program, not a person, reads the output. A parser expecting JSON fails on a friendly preamble, and a dashboard expecting three bullet points breaks on five. A precise format specification turns free text into predictable, machine-readable output.
How an output format instruction shapes model responses
An output format instruction works by conditioning the next-token probabilities toward a recognizable structure. Language models have seen enormous amounts of JSON, Markdown, CSV and XML during training, so naming a format and showing its shape makes tokens that fit that structure far more likely than conversational prose.
Effective instructions usually combine several elements. The table below lists the components that practitioners specify and what each one controls.
| Component | What it controls | Example wording |
|---|---|---|
| Format type | Overall syntax | Return valid JSON only |
| Schema or fields | Required keys and their types | Keys: title (string), score (integer 1-5) |
| Ordering | Sequence of parts | Answer first, then the reasoning |
| Length limits | Size of each part | At most three bullet points of 15 words |
| Delimiters | Boundaries for extraction | Wrap the final answer in answer tags |
| Exclusions | What must not appear | No preamble, no closing remarks |
| Fallback value | Behavior when data is missing | Use null when a field is unknown |
Instructions placed near the end of the prompt, close to where generation begins, tend to be followed more reliably in long prompts, because recent tokens strongly influence what comes next. Many teams state the format once in the system message and repeat it briefly after the user content.
Common output formats and when to choose them
The right format depends on who or what consumes the output. Structured formats suit software pipelines, while lightly structured formats suit human readers who still benefit from consistency.
| Format | Best consumer | Strength | Typical failure |
|---|---|---|---|
| JSON | Application code and APIs | Direct parsing into objects | Trailing commas, unescaped quotes |
| XML-style tags | Extraction scripts | Clear section boundaries | Missing closing tag |
| Markdown table | Human readers | Easy comparison | Misaligned column counts |
| CSV | Spreadsheets and data tools | Compact rows | Commas inside values |
| Numbered list | People following steps | Clear sequence | Merged or skipped steps |
| Fixed template | Reports and forms | Consistent layout | Placeholder text left in place |
When the consumer is code, JSON with an explicit schema is the usual default. For long documents with several parts, XML-style delimiters are often more robust than JSON, because the model does not need to escape quotation marks or line breaks inside free text.
Format instructions compared with related prompting techniques
An output format instruction is one of several ways to control response structure, and it is often combined with neighboring techniques in the Prompting topic. The comparison below shows how they differ in mechanism and strength of guarantee.
| Technique | Mechanism | Strength of guarantee |
|---|---|---|
| Output format instruction | Natural-language description of the format | Probabilistic, usually high |
| One-shot or few-shot example | Demonstrates the exact shape | Higher, but examples may be copied too closely |
| Prompt template | Reusable prompt with slots | Depends on the instruction inside it |
| Response prefilling | Starts the answer with an opening brace or tag | High for the first tokens |
| Structured outputs or JSON mode | Decoder constrained to a schema | Near deterministic validity |
| Function or tool calling | Arguments generated against a declared schema | High, enforced by the API |
The key distinction is between asking and enforcing. A format instruction asks the model to comply; constrained decoding makes invalid tokens impossible. Even with enforcement, the instruction still matters, because a schema guarantees valid syntax but not sensible field content.
Writing reliable format specifications
Reliable format instructions are specific, consistent and testable. Vague wording such as “keep it structured” leaves the model to guess, while an explicit schema with types and allowed values removes ambiguity.
- Show the exact shape with a short skeleton or one complete example, using realistic values rather than placeholders.
- Define every field with its type, unit and allowed range, for example a confidence score from 0 to 1.
- State the edge cases: what to output when information is missing, ambiguous or out of scope.
- Forbid surrounding prose explicitly when code will parse the response.
- Keep instructions consistent: a prompt that says “use bullets” in one place and shows a table elsewhere invites mixed output.
- Validate every response in code and retry or repair when parsing fails.
Reasoning and formatting can conflict. Forcing a model to emit only a short JSON object may suppress useful intermediate reasoning, so many designs include a dedicated reasoning field placed before the final answer field.
Failure modes of output format instructions
Format instructions fail in recognizable patterns, and most of them can be traced to ambiguity, competing instructions or excessive output length. The table pairs common symptoms with their usual causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Preamble before JSON | Conversational habit of chat models | Prefill the opening brace or forbid preamble |
| Invented extra fields | Schema not marked as closed | State that no other keys are allowed |
| Truncated output | Token limit reached mid-structure | Raise the limit or shorten fields |
| Format drift in long sessions | Instruction buried far back in context | Repeat the format near the end |
| Wrong value types | Types not specified | Give types and an example value |
A subtler risk is that strict formatting can reduce answer quality on complex tasks, because the model spends capacity on syntax. Measuring accuracy with and without the format constraint, as part of prompt evaluation, shows whether the trade-off is acceptable.
The idea in brief
Asking a model a question is like asking a colleague for information. An output format instruction is the part where you also say how you want the answer handed back: as a filled-in form, a short list or a table, rather than a loose paragraph.
This matters because answers are often read by software, and software needs everything in the same place every time. A clear format instruction is the difference between a reply someone must retype and one that drops straight into the next step.
A practical scenario
A customer support team uses a language model to sort about 3,000 incoming emails per day. The first prompt simply asked the model to classify each message, and the replies varied: some gave a category name, some wrote a paragraph, and the routing script failed on roughly 8 percent of messages.
The team rewrote the prompt with an explicit output format instruction: return a JSON object with the keys category (one of six listed values), urgency (an integer from 1 to 3) and summary (at most 25 words), with no other text. They added one worked example and a rule to use “other” when no category fits.
After the change, parsing failures dropped to well under 1 percent, and the remaining cases were caught by a validator that retried the request once. Agents now see a consistent summary and urgency level for every ticket.