Structured output (JSON, simply)
- prompting
- structured output
Structured output is output shaped for a destination — a spreadsheet column, a checklist, a field list your tool can read. Most AI answers are written for a human reader: fluent prose you have to re-type before it is useful. Asking for a fixed shape changes that. And you do not need to be a programmer: you need to name the shape.
Three levels of shape
- A table or list — for humans and spreadsheets. “A markdown table with columns: Vendor, Due date, Amount.”
- Fixed fields — for partial reuse. “For each item, output three lines: Name:, Deadline:, Owner:.”
- JSON — for tools. “A JSON array where each object has the keys invoice, due, amount.” JSON is just labeled data; the keys are the labels.
The recipe
- Name every column before asking for rows. “Organized” is a hope, not a format.
- Show one example row. A single filled row communicates the shape better than a paragraph about it — the same signal as examples and few-shot.
- Ask for nothing else. “Output only the table.” By default, answers come wrapped in polite commentary that breaks every tool that tries to read them.
- Decide what happens to missing values. “If a field is absent, write ‘not found’” — a placeholder convention. Without a rule, gaps get filled — and you cannot tell which cells are real.
A bad example
Ask: “Summarize these invoices in a clear, organized way.”
Clear to whom? You get elegant prose — and an afternoon of re-typing it into a sheet.
A better example
Ask: “Here are three invoices: [paste]. Extract one row per invoice into a markdown table with columns: Vendor, Invoice number, Due date, Amount. Use ‘not found’ when a field is missing. Output only the table.”
Now the answer pastes into a spreadsheet, and every gap is visible instead of invented.
Test the shape before you run it
Ask for the first two rows only and check the shape. Fixing a column name costs one follow-up; re-deriving two hundred rows costs the afternoon. When you do get JSON, confirm it actually parses before trusting it downstream — chat interfaces often add a friendly sentence or wrap long lines, which breaks importers silently. The shape is a promise the model usually keeps, but you are still the one who checks.
Why it works
Models are pattern machines: a named shape plus one example row is the strongest pattern signal you can give, and it leaves nothing to improvise. Free-form requests leave the structure to chance; fixed fields leave it to you.
Practice
Assemble a structured-output prompt
A teammate needs the three supplier invoices on their desk turned into rows — vendor, invoice number, due date and amount — ready to paste into a budget spreadsheet.
Fill every field to assemble a prompt that asks for a clean table instead of prose. The preview shows exactly what you would send; then compare it with a strong example.
A strong example (self-assessment — not machine-graded)
Extract one row per supplier invoice from the three invoices below, into a markdown table with exactly these columns: Vendor | Invoice number | Due date | Amount. If a value is not present in an invoice, write 'not found' in that cell — never guess or calculate it. Output only the table, with no commentary before or after it. Invoices: [paste the three invoices]
Hint
A column list is a format; 'organized' is a hope.
What happens to a due date the invoice never mentions? Decide before the model does.
Why this is the answer
The assembled prompt names every column, defines the container (a table), writes in the missing-data rule and blocks the default behaviour — polite commentary wrapped around the data. One example row would make it even stronger: a filled row communicates the shape more precisely than any description can.
Transfer
- Meeting notes → an action table with Owner and Due columns.
- Job postings → keyword fields per posting for a comparison sheet.
- Any “turn this into something I can paste” request: answer with the destination format, not a nicer paragraph.
Next
Next: Iterate from the output — the first draft is a draft; here is how to steer it without starting over.