DT
←
Back to Blog
AI EngineeringDecember 13, 2025 β€’ 8 min read

Understanding Schema-Enforced
Outputs

If you've integrated an LLM by parsing its output with regex, you've likely experienced the moment when everything breaks. It's time to make the model speak JSON.

πŸ“ Show Notes & Ideasβ–Ό
πŸ“
Notes & Ideas

Danny's Quick Rules for Schemas:

  • β†’Regex is not a Parser. Stop parsing LLM output with regex. It works for 100 examples and breaks on the 101st.
  • β†’Use Native Structured Outputs. OpenAI, Anthropic, and Gemini all support JSON mode or Tool Use. This isn't a suggestion; it's the standard.
  • β†’Type Safety is Mandatory. If you can't satisfy TypeScript at compile tiime, you shouldn't be shipping it. Use Zod to define your runtime contract.
  • β†’Validation > Correction. Don't try to "fix" bad JSON. Reject it. Force the model to retry or fail gracefully.

The Bottom Line:

Unstructured text is for humans. Machines need schemas.

0

Β© 2026 DTHOMPSONDEV. All rights reserved.

RRSS Feed