
Getting AI to return clean, structured output is the difference between a result you can use immediately and one you have to reformat by hand. These techniques give you JSON, tables, or any format you need, every time.
TLDR
Show the model an exact example of the format you want: an empty JSON schema, a table with headers, or a single completed example. Be explicit about every field, including what to return when data is missing.
Show an exact example of the structure
Do not describe the format: show it. Paste an example of the exact JSON schema, table structure, or list format you want filled in. The model mirrors a shown example far more reliably than it follows a text description.
Specify how to handle missing data
If a field might not have a value, tell the model exactly what to return: null, an empty string, "N/A," or omit the field entirely. Unspecified behavior produces inconsistent handling across records.
Test with one record before the full batch
For large structured outputs, ask the model to produce one complete example first and confirm it matches before asking for the full set. Catching format errors on record one saves you from reformatting fifty.
Prohibit extra commentary
By default, AI models often add explanatory text before or after structured output. Add "return only the JSON, no explanation or surrounding text" to get clean output ready for parsing.
Use JSON mode for production applications
If you are building something programmatic, use the JSON mode available in the ChatGPT and Claude APIs. It enforces valid JSON at the model level, eliminating parsing failures from malformed responses.
Example prompt
Product review extraction: schema shown, field types specified, null handling defined, commentary prohibited
Extract the following product information from the review text below and return it as a JSON array. Use exactly this schema for each product: { "product_name": string, "rating": number (1-5), "main_complaint": string or null, "main_praise": string or null, "would_buy_again": boolean } Return only the JSON array. No explanation or surrounding text. [Paste review text here]
Feeding output into code or a database
When AI output will be parsed by code, inconsistent formatting breaks everything. Structured output prompts make AI output reliable enough to use programmatically without manual cleanup.
Extracting data from unstructured text
Converting emails, documents, or web content into structured records is one of the most valuable AI use cases and requires precise format control to work reliably.
Building consistent reports
When you need the same structure every time, such as weekly reports, competitive analyses, or meeting summaries, structured prompts ensure the format is consistent across every run.
Describing the format instead of showing it
"Return a JSON object with a name field, a date field, and a list of items" is harder to follow than showing the actual empty schema. Always show, do not describe.
Not specifying edge cases
What should happen when a field is empty, multiple values exist, or data is ambiguous? If you do not specify, the model makes its own inconsistent choices.
Asking for structure and analysis in the same prompt
Asking for JSON and a written explanation in one prompt often produces mixed-format output. Separate them: structure first, then a follow-up prompt for analysis if needed.
Show the exact schema as an example, specify field types and null handling, and say "return only JSON with no explanation." For production use, enable JSON mode in the ChatGPT or Claude API.
Yes, with multimodal models. Paste the document content or image and provide your JSON schema. Accuracy depends on the clarity of the source document.
Add this line to your prompt: "Your response must begin with { or [ and contain nothing else." This is more specific than asking it to omit explanation and typically eliminates the problem.
Bottom line
Show the exact format you want rather than describing it. Specify field types, null handling, and prohibit extra commentary. For production applications, use JSON mode in the API.
Prompt packages that apply this technique directly.
Technical Documentation
Creating comprehensive technical documentation can overwhelm teams, leaving critical gaps or unclear instructions.
See promptsResearch
Research with AI works best when you treat it as a thinking partner, not a search engine.
See promptsCode Review
Most code reviews either miss real problems or create friction without adding value.
See prompts