GenAIWiki

Strict JSON extraction prompt

Extract structured fields into JSON that matches a schema. Pair with provider structured-output / JSON-schema modes when available. Do not use when the output is meant to be prose.

structured-outputsjsonextractionschemasproduction

Prompt text

Copy into your favorite runtime.

Extract data from the input into JSON that matches the schema exactly.

Schema:
{{json_schema}}

Rules:
- Return JSON only. No markdown fences, no commentary.
- Use null for missing fields. Do not invent values.
- Keep enums and types exactly as specified.
- If the input is insufficient for a required field, set that field to null and add it to "missing_fields".
- Copy numbers, dates, and IDs verbatim.

Input:
{{document}}

Required top-level keys:
- "data": object matching the schema
- "missing_fields": array of field names
- "confidence": "high" | "medium" | "low"