Structured outputs and reusable prompt patterns

When output feeds a spreadsheet, a script or a colleague, its shape stops being cosmetic.

intermediate8 minChecked 2026-09-06

What you will be able to do

Get consistent, machine-readable output and build a small library of prompts you actually reuse.

Before you start

  • Comfort with the idea of a table or JSON object.

Specify the shape, and show it

Describing a format works. Showing one worked example works better. Give the field names, the types, what to do when a value is missing, and one filled-in row.

Say explicitly what should happen with unknown values — an empty string, a null, the word unknown. Left unspecified, the model will invent something reasonable and inconsistent.

Where structure pays

Extraction into a spreadsheet. Classification. Anything a script will read. Anything you will do fifty times and want to compare.

Where it does not: drafting prose, thinking out loud, exploring an idea. Forcing structure onto those degrades them.

A library, not a pile

A reusable prompt has three parts kept separate: the stable instruction, the changing input, and the evaluation criteria. Keep them in one file per task with a note on when it works and when it does not.

Most people's prompt collections fail because the stable and changing parts were written as one blob and cannot be updated safely.

Extraction with an explicit shape
Extract every event mentioned in the text below into JSON.

Schema: an array of objects with keys title (string), date (ISO 8601 or null), venue (string or null), price (string or null).

Rules: use null where the text does not state a value. Do not infer a year that is not written. Do not include events that are only alluded to. Return only the JSON, no commentary.

Example of one correct object:
{"title":"Panorama","date":"2026-08-29","venue":"Kensington and Chelsea","price":null}

Text:
---
[paste here]

What good looks like

  • The same prompt returns the same shape across ten different inputs.
  • Missing values are consistent rather than improvised.
  • You can point a script at the output without cleaning it first.

What it cannot do

  • Format adherence is high but not guaranteed without a provider-side structured-output feature.
  • Extraction quality depends on the source being unambiguous.

When it goes wrong

Occasional prose wrapped around the JSON.
Say "return only the JSON" and check whether your tool offers a structured-output mode, which enforces this properly.
Invented values in place of missing ones.
State the null rule explicitly and give an example containing a null.

Privacy and data handling

Structured extraction is often applied to personal data. Confirm your lawful basis and retention position before running it at scale.

Sources3 referenced
  1. OpenAI platform documentation

    OpenAI · official product documentation · link checked 2026-09-06

  2. Claude developer documentation

    Anthropic · official product documentation · link checked 2026-09-06

  3. Guidance on AI and data protection

    Information Commissioner's Office · regulatory guidance · link checked 2026-09-06

Links are checked at build time. If one has moved, tell us.

Written by
BLACK LDN
Last checked
2026-09-06
Content state
editorial

Product behaviour changes. If something here no longer matches the documentation, send a correction.

Read next

Writing good instructions8 min

Iterate, evaluate and improve

The difference between someone good at this and someone frustrated by it is usually a habit of changing one thing at a time.

intermediate

Checked 2026-09-06

Giving it the right information9 min

What context engineering actually means

Prompting is what you ask. Context engineering is what you put in the room before you ask it. The second is where most of the quality lives.

intermediate

Checked 2026-09-06

Next: What context engineering actually means