Get Strict Structured JSON From a Prompt
Rewrite a prompt so the model reliably returns valid, schema-conforming JSON — with the schema and failure handling spelled out.
0 likes
0 dislikes
Sign in to rate this prompt
Prompt
Help me get reliable, valid JSON out of a prompt.
What I want the model to produce (describe the data, or paste an example of the ideal output):
{{goal}}
My current prompt (optional):
{{prompt}}
Please:
1. **Define the schema** — the exact JSON shape: field names, types, which are required, allowed values/enums, and how to represent "unknown" or "not applicable".
2. **Rewrite the prompt** so it states the task, includes the schema, instructs the model to return ONLY the JSON (no prose or markdown fences), and says what to do when a value can't be determined (use null, don't invent).
3. **Add one worked example** of a valid response — a concrete example constrains format better than description alone.
4. Note how I'd validate the output (parse, then check against the schema) and what to do on a parse failure.
If the platform supports a native structured-output / JSON-schema mode, mention that as the more robust option and how it changes the prompt. If my desired shape is ambiguous, ask before finalizing the schema.