The problem
JSON from a model is fine in the demo and flaky in production. It wraps the object in prose, renames a field, returns a string where your parser wants a number, and a model update silently changes the shape your code depended on. Getting JSON you can build on isn't one prompt — it's defining the contract, forcing the output to it, checking every response against it, and having a way to see exactly what changed when something drifts.
Recommended workflow
Each step uses an existing NewPrompt tool, pre-filled by a matching resource. Open the resource to read it,
or jump straight into the tool with the inputs ready.
-
1
Define and force the JSON contract
Specify the schema the output must match — fields, types, nesting — and force clean JSON with no prose wrapper, so there's one definition of correct and the model returns only that.
Outcome
Schema-constrained JSON with no prose around it.
-
2
Validate every response
Check each response against the schema and catch the drift — a missing field, a wrong type, an invalid value — before your parser does.
Outcome
Each response confirmed valid, or a repair prompt when it's not.
-
3
Diff the drift
When a model or prompt change shifts the output, diff the new response against a known-good one to see exactly what moved — so you catch a breaking change before it ships.
Outcome
A clear view of what changed when the shape drifts.
Expected outcome
JSON that holds its schema call after call, validated before it reaches your code, with a way to spot exactly what drifted when a model update changes the shape — output you can build on, not babysit.
Best for
- Wiring AI output into code that parses JSON
- Keeping a JSON response stable across model updates
- Catching format drift before it breaks a parser
Not for
- Extracting fields from documents — use the AI Data Extraction Workflow
- A one-off where you eyeball the JSON yourself
FAQ
AI JSON output workflow vs data extraction workflow
Data extraction pulls fields out of source text into JSON — the source drives it. This JSON output workflow makes any AI task return schema-valid JSON your code can parse, and adds drift-diffing across model versions. One is about the source; this is about the output contract.
What do I get from the AI JSON output workflow?
You get JSON that holds its schema call after call: a forced schema contract with no prose wrapper, a validation step that flags missing fields or wrong types before your parser, and a diff of the new response against a known-good one when a model update shifts the shape.
How do I run the AI JSON output workflow?
Work the three steps in your own AI tool: define and force the JSON contract with the JSON Output Prompt Builder, validate every response against the schema with the AI Output Validator, then diff drift with the Text Diff Checker. NewPrompt supplies the prompts and order; you run them.
AI JSON output broke after a model update — how do I fix it?
Diff the new response against a known-good one from before the update to see exactly what moved — a renamed field, a number returned as a string. Then re-run the validate step and, if needed, tighten the forced schema contract so the model returns the shape your code expects.
Why diff outputs if I'm already validating?
Validation tells you a response is invalid. Diffing tells you what changed — invaluable when a model update quietly alters the shape and you need to compare today's output against last week's known-good one.
Does forcing JSON guarantee valid JSON?
It makes it far more likely, not certain. Models still drift, which is why validation is a separate step — forcing shapes the output, validating confirms it.