Skip to content
promptintermediateFree

Structured JSON output

Get valid, schema-shaped JSON from free text every time, with nulls instead of guesses, ready to feed into code or a spreadsheet.

You'll need: A JSON Schema or example object describing the shape you want

Fill in your details

Values are inserted into every prompt below. Nothing you type leaves your browser.

3 field(s) left — unfilled variables stay as {{placeholders}}.

  1. 1Write the schema

    A short JSON Schema or an example object with types works. Keep field names in snake_case and add enums wherever there's a fixed set of values; enums are the biggest single improvement to consistency.

  2. 2Run the prompt

    In API use, prefer the provider's native structured-output or JSON mode with this schema and keep the prompt for the extraction rules. In chat, this prompt alone works for most cases.

    Task: {{task}}
    
    Return a single JSON object that conforms to this schema:
    {{json_schema}}
    
    Rules:
    - Output only the JSON object. No prose, no markdown code fences.
    - Use exactly the keys in the schema. Do not add keys.
    - If a value is not stated in the input, use null. Do not guess or use typical values.
    - Strings must be copied from the input where possible; dates as YYYY-MM-DD; numbers without units or thousands separators.
    - For enum fields, use only the allowed values; if none fits, use null.
    
    Input:
    {{input_text}}
  3. 3Validate

    Paste the output into a JSON validator or schema checker before using it. If it fails, send the validation error back to the model and ask for a corrected object only.

Example input

A job posting: 'Senior Data Engineer at Northwind, London (hybrid, 2 days in office). £75,000-£90,000 plus bonus. Apply by 30 Nov.'

Example output

{"title":"Senior Data Engineer","company":"Northwind","location":"London","remote":"hybrid","salary_min":75000,"salary_max":90000,"currency":"GBP"}

Troubleshooting

  • Output is wrapped in ```json fences: strip them in code, or repeat 'no code fences' at the end of the prompt.
  • The model invents values for missing fields: make the null rule the first rule and add an example with nulls.
  • Nested arrays come back inconsistent: provide one complete example object alongside the schema.

Known limitations

  • Prompt-only JSON can still be invalid occasionally; validate before use, or use native structured outputs in the API.
  • Very large schemas (dozens of fields) reduce accuracy; split into two passes.

More from ChatGPT / Claude / Gemini