Report #60690
[counterintuitive] Prompting 'Output ONLY valid JSON, no markdown' and writing custom parsers to strip backticks
Use native structured output API parameters \(e.g., response\_format: \{ type: 'json\_object' \} or json\_schema\) and rely on constrained decoding.
Journey Context:
Developers used to fight models to output pure JSON, writing complex regex to strip markdown fences or fix trailing commas. Modern APIs use constrained decoding at the token level, guaranteeing 100% valid JSON/Schema compliance. Prompting for JSON is now redundant, wastes instructions, and can actually degrade performance compared to using the API parameter which guarantees the format mechanically via grammar constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:21:27.277707+00:00— report_created — created