JSON Mode Prompt — With and Without Native Support
Native JSON modes guarantee syntax, not your schema. The prompt contract that covers field names, types, and null discipline — whether or not the API has JSON mode.
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
Asking for JSON politely fails in three ways: the model wraps the object in prose, fences it in markdown, or invents fields you never asked for. Forcing JSON reliably takes a contract, not a request: a schema with explicit types and requirements, a realistic example response the model can imitate, validation rules for nulls and types, and a strict rule block that bans everything except the object itself. This resource loads a complete strict-mode contract so you can see all four parts working together — then adapt the schema to your own data.
Open the loaded contract
The customer-record schema loads in Strict mode. Generate and read the four sections — each handles a different failure mode.
Swap in your fields
Replace the schema fields with your own; the example response regenerates with realistic values automatically.
Test at Standard first
If your model behaves, Standard's four rules cost fewer tokens. Escalate to Strict only when prose leaks through.
The strict OUTPUT RULES name each leak by itself: output only valid JSON, no explanations, no commentary, no markdown, no code fences, exactly one object, no trailing commas, instead of just saying "only JSON" and hoping. A realistic EXAMPLE OF A VALID RESPONSE reinforces it, since models imitate examples. The json-output-prompt-builder generates the contract; you run it and still JSON.parse defensively.
Strict loads the full OUTPUT RULES block that bans each failure mode by name; Standard uses four rules and costs fewer tokens. The workflow advises testing at Standard first and escalating to Strict only when prose leaks through. Both keep the null discipline: optional fields set to null, never omitted. The json-output-prompt-builder produces whichever you pick, and the model you run it in isn't guaranteed to comply, so validate output.
The prompt-side syntax rules matter less there, but the notFor is explicit that the schema rules still apply: native structured output guarantees valid JSON, not that the right fields with the right types show up. The SCHEMA, VALIDATION RULES, and "use null for unknown values — never invent data" still earn their place. The builder produces the contract; you decide how much native mode makes redundant.
Native JSON modes guarantee syntax, not your schema. The prompt contract that covers field names, types, and null discipline — whether or not the API has JSON mode.
When the destination is a spreadsheet, CSV is the contract: one header row, one data row, quoting rules, and an honest answer about nested data.
Automation platforms fail silently on malformed model output. The strict contract that keeps AI steps feeding clean JSON into the rest of the flow.
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
'Make it good', 'be detailed', 'keep it interesting' — vague prompts get vague output. The fix is mechanical: replace every fuzzy word with a checkable instruction.
Build prompts that return structured data — JSON first, with YAML, XML, and CSV modes — parseable every time.
Turn messy text into structured data you can trust enough to feed another system — bound the source, extract the fields, force clean JSON, and validate before it flows downstream.
AI models return broken JSON more often than you'd expect. Here's how to structure a prompt so the output parses cleanly, plus what to check before you trust it.
The AI nails your format once, then the next output adds a "Sure, here's…" wrapper, renames a field, turns the table into bullets, and drops a section. Here's how to write the format as a contract and catch the drift when it happens anyway.