Structured output prompting get clean JSON, CSV, or tables from AI
Show the model the exact shape you want, and it fills in the data.
In short
Structured output prompting means telling the AI the exact format you want, like JSON, CSV, or a table, so the result is ready to use.
- Show the shape with an example: the fields, the columns, one filled-in row. Do not just say 'in JSON.'
- Ask for a downloadable file when you want CSV or a spreadsheet you can open directly.
- Validate the output. Even flagship models return slightly malformed structure a small share of the time.
Show the shape you want
Structured output prompting is asking the model to return data in a fixed format: JSON, CSV, a table, or a set of named fields. You can drop the result straight into a sheet or another tool. The trick is to show the shape, not just name it. 'Respond in JSON' on its own slips into the wrong structure a small but real share of the time. Paste the exact fields you want with one example filled in, and the model copies that pattern reliably. The example you paste is few-shot prompting doing the work, and the most common use is getting spreadsheet analysis back in a usable shape. It is a practical corner of prompt engineering.
How to use structured output prompting
Name the format, show one example, and say how to handle gaps.
- 1
Name the format
State it plainly: 'return this as JSON,' 'give me a CSV,' 'answer as a table with these columns.'
- 2
Show the exact shape
Paste the fields or columns you want with one example row filled in. The example does more than any description.
- 3
Say what to do with gaps
Tell it how to handle missing data: 'use null,' 'leave blank,' 'write unknown.' Otherwise it invents a value to fill the slot.
- 4
Ask for a file when you need one
For CSV or a spreadsheet, add 'give me a downloadable file' and it produces one you can open directly.
- 5
Validate before you use it
Open the result and check the structure, especially anything you will paste into another system, where a stray comma breaks the import.
A structured-output prompt
Watch-outs
- The example row is the whole trick. Without it, the model guesses at your structure.
- Check the output, especially quotes and commas in CSV. A small format slip breaks the next tool.
- For big or repeated jobs, the API's structured-output mode is more reliable than the chat window.
Common questions
How do I get JSON output from ChatGPT?
Ask for JSON and show the exact shape: paste the fields you want with one example filled in, and tell it how to handle missing values. Naming the format alone works most of the time; the example is what makes it reliable.
Why does ChatGPT return the wrong format?
Because 'respond in JSON' leaves the structure up to the model, and it guesses at your fields. Show a worked example of the exact shape and specify what to do with gaps, and the format lands almost every time.
Can ChatGPT make a CSV or Excel file?
Yes. Describe the columns and add 'give me a downloadable file,' and it generates a CSV or spreadsheet you can open. For a quick paste, ask for the data as a table or CSV text instead.
What is structured output prompting?
It is prompting the AI to return data in a fixed, machine-ready format such as JSON, CSV, or a table, by showing it the exact shape you want. It turns a paragraph you would have to reformat into output you can use directly.
See how you actually work with AI
The AI Skills Quiz scores your real habits, including how precisely you shape the model's output. Free, and it takes a couple of minutes.
Professionals from these companies build their AI skills with Candova
The future belongs to AI‑native companies.
Make sure yours is one.
We make your people AI-fluent so your company becomes AI-native, with Cando, a personal AI trainer for every employee. Start with Candova AI today.
Free to start · Productivity gain guarantee · Built for your real job