---
title: "Discussion on \"Your AI Feature Is Lying to You: Stop Using JSON Mode and Use Schema-Constrained Outputs\" | Hashnode"
description: "Discussion on \"Your AI Feature Is Lying to You: Stop Using JSON Mode and Use Schema-Constrained Outputs\". JSON mode silently corrupts your AI features. Learn how schema-constrained generation with Zod + OpenAI strict mode fixes it for MERN stack apps."
url: "https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Your AI Feature Is Lying to You: Stop Using JSON Mode and Use Schema-Constrained Outputs](https://blog.thecodingant.in/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs?utm_source=hashnode&utm_medium=feed)

JSON mode silently corrupts your AI features. Learn how schema-constrained generation with Zod + OpenAI strict mode fixes it for MERN stack apps.

Oct 3 · 7 min read · blog.thecodingant.in  
Updated Oct 4  
Read the article

-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#ai](https://hashnode.com/tag/ai)
-   [#webdev](https://hashnode.com/tag/webdev)
-   [#openai](https://hashnode.com/tag/openai)

## Written by

[Nitesh Kumar Tudu](https://hashnode.com/@nitesh000)

@nitesh000 · Rourkela, India

  
[View profile](https://hashnode.com/@nitesh000)

Love to type, cool tech and coding. and Btw I use Vim.

Love to code, gaming. And I use vim btw.

## Responses 9

Markdown supported · ⌘↵ to post

[Julian Neagu](https://hashnode.com/@julianneagulab)

[Oct 6](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac4c10691bd6099f9c16b73)

The cents point is underrated. I’ve had AI outputs behave way better once the schema makes units explicit. `totalAmountCents` leaves a lot less room for weird guesses.

[Puneet Khandelwal](https://hashnode.com/@lifestyle4u)

[Oct 4](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac22a1a706b4eb4602da18a)

Spot on. JSON mode just stops syntax errors, but schema enforcement is the only way to actually stop runtime hallucination.

[Jen Zawaski](https://hashnode.com/@itcodegirl)

[Oct 4](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac1e487851d3053dfa946e1)

Anthropic is outdated in the article. Anthropic now has JSON outputs and strict tool use that guarantee schema-compliant responses through constrained decoding. The parameter moved from output\_format to output\_config.format, and the old one is deprecated.

[Nitesh Kumar Tudu](https://hashnode.com/@nitesh000)

[Oct 4](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac1e487851d3053dfa946e1#reply-6ac27e11b47b1c1452200be0)

Thnx for pointing out🫡

[X1Y1](https://hashnode.com/@x1y1)

[Oct 3](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac112590b1cc3a3ac686a8a)

The vendorName/clientName swap you opened with is the sharpest example in here, and it's worth calling out explicitly: strict schema enforcement wouldn't have caught it either. Both fields are valid strings in the right slot, so json\_schema with strict:true passes the exact same way json\_object mode did. Structural validity and correctness are different guarantees. The only way to catch the swap is a semantic check: a handful of invoices with known field values, asserted after extraction, rerun whenever the prompt or model changes.

[Nitesh Kumar Tudu](https://hashnode.com/@nitesh000)

[Oct 4](https://hashnode.com/posts/your-ai-feature-is-lying-to-you-stop-using-json-mode-and-use-schema-constrained-outputs/6ac1044a4835cefdf58bcc41/comment/6ac112590b1cc3a3ac686a8a#reply-6ac27cbe163847d2c0fce3a9)

True, can't be too dependent on model output. All models behave very differently even under the same prompt. The structural validation is not optional, it's a necessity.
