← Back to Tools

JSON Schema Validator

Debug OpenAI function calling outputs. Paste your Schema and the AI's JSON output to check for errors.

Mastering JSON Schema Validation for AI

1. What is this tool?

When building AI Agents (using OpenAI, Claude, or Gemini), you often use Function Calling (or Tool Use). You define a "Schema" that tells the AI: "If you want to call the 'send_email' function, you MUST provide an 'email' string and a 'subject' string."

2. Why do validation errors happen?

LLMs are probabilistic. Sometimes they hallucinate or mess up formats. They might:
• Return a string "five" instead of number 5
• Return invalid JSON (missing comma)
• Forget a required field like email

3. How to fix errors?

If validation fails here, you need to improve your System Prompt or Schema Description.
Error: "must be number" → Tell AI: "Always output age as a number, not string."
Error: "missing property" → Mark the field as required in your schema.

Common Validation Scenarios

type: "integer"

Mistake: AI returns 5.5
Fix: Change type to number if decimals are allowed, or prompt AI "Integers only".

format: "email"

Mistake: AI returns "john at gmail"
Fix: Use the validator to catch this. AJV checks standard regex patterns.

additionalProperties: false

Mistake: AI hallucinates extra fields.
Fix: Set this flag in your schema to force strict adherence.

📚 Read Guide: Master OpenAI Function Calling & JSON Schemas →