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.
Why this prompt works
-
Claude vs Gemini vs ChatGPT
Google's Flash rate doubles on 1 January 2027 and its flagship is still preview; OpenAI spans 50x from Luna to Astra with no retirement d...
Read the guide → -
ChatGPT vs Claude
Both flagships now cost exactly $10/$50 — but Anthropic's tokenizer fits 555k words into a million tokens where the old one fit 750k, so ...
Read the guide → -
How to Deploy an AI Agent
Every deployment problem follows from one property: you don't know how long a run takes, because you didn't write the path. Why the run m...
Read the guide →