STRUCTURED OUTPUTS UTILITY

LLM Structured Outputs JSON Schema Validator & Auto-Fixer

Paste your function-calling or response_format JSON Schema to pinpoint exact rules that trigger HTTP 400 rejections across OpenAI, Claude, and Gemini—and copy a normalized strict schema in one click.

ExecutionZero login · 100% browser-localSchema rules checked November 11, 2026
01

Structured outputs JSON Schema validator and auto-fixer

Paste your tool or response_format JSON Schema to catch HTTP 400 compatibility errors and generate a normalized strict schema automatically.

Validation status6 blocking schema issues detected
Auto-fixed strict JSON Schema
request.example
{
  "type": "object",
  "properties": {
    "invoiceId": {
      "type": "string"
    },
    "currency": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "USD",
        "EUR",
        "GBP"
      ]
    },
    "totalAmount": {
      "type": "number"
    },
    "customer": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "taxId": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "taxId"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "invoiceId",
    "currency",
    "totalAmount",
    "customer"
  ],
  "additionalProperties": false
}

Compatibility diagnostics

  • $.additionalPropertiesStrict mode requires every object schema to set "additionalProperties": false.
  • $.required (currency, customer)OpenAI strict mode requires every property to be listed in required; optional properties were converted to nullable unions.
  • $.properties.invoiceId.patternStrict structured outputs commonly reject value-constraint keywords; move the rule into description and enforce it in application code with Zod or Pydantic.
  • $.properties.totalAmount.minimumStrict structured outputs commonly reject value-constraint keywords; move the rule into description and enforce it in application code with Zod or Pydantic.
  • $.properties.customer.additionalPropertiesStrict mode requires every object schema to set "additionalProperties": false.
  • $.properties.customer.required (taxId)OpenAI strict mode requires every property to be listed in required; optional properties were converted to nullable unions.
02

Engineering reference and rollout checks

Why valid Draft-07 JSON Schemas still fail with HTTP 400 on LLM APIs

Constrained-decoding engines compile your JSON Schema into a context-free grammar or finite-state token mask before generation starts. To keep grammar compilation fast and bounded, OpenAI, Anthropic, and Google each enforce a stricter subset of JSON Schema than standard Ajv, Zod, or Pydantic exporters emit by default.

For example, OpenAI's strict: true mode rejects any object node that omits additionalProperties: false OR leaves a property out of the required array—meaning optional fields must be represented as nullable unions (["string", "null"]) while still appearing in required. Conversely, Google Gemini's generationConfig.responseSchema rejects the additionalProperties keyword altogether.

Schema ruleOpenAI Strict (strict: true)Anthropic Strict Tool / JSONGemini responseSchema
Root type must be "object"RequiredRequiredRecommended
"additionalProperties": false on every objectRequired (400 if omitted)Required (400 if omitted)Rejected (400 if present)
All properties listed in "required"Required (use [type, "null"] for optional)Optional keys allowedOptional keys allowed
Regex pattern / minLength / formatUnsupported in strict grammarLimited; prefer description + app checkUnsupported on most string formats

Production checklist for reliable structured extraction and tool schemas

Auto-fixing grammar rejections gets your request past HTTP 400, but reliable extraction also depends on clear semantics inside the schema. Keep field names self-explanatory, avoid deeply nested recursive trees, and always handle model refusals explicitly.

  • Move regex patterns, string length bounds, and numeric ranges into the field's description and enforce them deterministically with Zod or Pydantic after parsing.
  • Check finish_reason (or stop_reason) for max_tokens truncation before calling JSON.parse—truncated JSON will fail parsing even when strict mode is enabled.
  • Handle explicit safety or policy refusal fields before reading parsed structured output.

Frequently asked questions

How do I represent an optional field in OpenAI strict mode?

Include the field name in the object's required array and change its type to a nullable union such as ["string", "null"]. The auto-fixer above performs this transformation automatically.

Why does Gemini reject a schema that works on OpenAI?

OpenAI strict mode requires additionalProperties: false on every object, whereas Gemini's OpenAPI-derived responseSchema parser rejects unknown keywords including additionalProperties. Switch the target dropdown above to Google Gemini to strip incompatible keys.

Should I still validate the LLM response with Zod or Pydantic?

Yes. Constrained decoding ensures matching JSON types and required keys, while your application validator enforces business invariants like positive currency amounts, valid dates, and authorized IDs.

Test your strict schema on a live model route

Copy the normalized JSON Schema above and validate it with a non-streaming request on LLMFly AI.

Get API Key