Watch: Get clean JSON from AI instead of messy text | Vovy
Watch Vovy do it on a Mac: "The AI keeps breaking my app with bad JSON. Make it return clean data". Use structured outputs with a JSON schema so the model always returns data your app can parse, instead of text that crashes JSON.parse.
"The AI keeps breaking my app with bad JSON. Make it return clean data"
Use structured outputs with a JSON schema so the model always returns data your app can parse, instead of text that crashes JSON.parse.
What happens in the video
- Find the parse failures: Vovy looks for errors like "Unexpected token" in your logs and shows examples where the model added prose or code fences around the JSON.
- Define the shape you need: Vovy asks Claude Code to write a JSON schema, a description of each field and its type, from the data your app expects.
- Turn on structured outputs: Claude Code passes the schema using the provider's structured output option, which forces replies to match it instead of just asking nicely.
- Validate on your side: Claude Code adds a validator like Zod so any unexpected reply is caught and retried, not crashing the screen.
- Run a stress test: Vovy sends 30 varied inputs and shows a table: parse success before and after, and any fields the model struggled with.
Read the step-by-step guideLoading...