ToolsPromptsSkillsWorkflowsBlogAbout

Structured Output Prompting — reliable JSON, XML, and table extraction

Force the AI to output in a strict schema using explicit format instructions, examples, and validation rules.

Prompting3.9
Structured Output Prompting — reliable JSON, XML, and table extraction preview

Prompt template

Extract the following information and output as valid JSON matching this schema:

{json_schema}

Rules:
- Output ONLY valid JSON, no markdown or explanation
- Use null for missing fields
- Arrays must contain at least 1 item if data exists

Input text: {input_text}

How to use

  1. 1Define a clear JSON schema with field types and descriptions
  2. 2Include 1-2 few-shot examples of correct output
  3. 3Add explicit 'output only JSON' instruction
  4. 4Validate output with JSON parser after generation
  5. 5Retry with error message if parsing fails

Pro tips

  • Use function calling / tool use when available for guaranteed schema
  • Include enum constraints for categorical fields
  • Add a 'raw_text' fallback field for unparseable content
  • Temperature 0 improves schema adherence

Works best with

Ratings & Reviews

Loading reviews…

Share your experience

Select a rating

Related Skills