API Response Schema Inferrer

Infer a JSON Schema draft-07 from a sample LLM API response or any JSON object.

Paste a raw LLM API response or any JSON object and instantly infer a JSON Schema draft-07 from it, ready for structured-output enforcement, response validation, or function-calling parameter definitions. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Which JSON Schema version does it output?

It emits JSON Schema draft-07, the version most widely supported by validators and by structured-output features in major LLM APIs. The output is plain JSON you can paste anywhere.

API response schema inferrer

When you call an LLM API and get back structured JSON, you often want a schema: to enforce that shape with structured outputs, to validate responses before parsing, or just to document what your code expects. Writing one by hand is tedious. This tool reads a real sample and produces a JSON Schema draft-07 describing it, instantly and entirely in your browser.

How it works

The tool parses your JSON and recursively walks the value tree. Strings, numbers, booleans, and null map to their JSON Schema types; objects become type: object with a properties map and a required list of their keys; and arrays become type: array with an items schema inferred from the first element. The result is a self-contained schema document you can copy and drop into a validator or an LLM structured-output config.

Example: inferring from a real API response

Input JSON (a sample LLM-generated product object):

{
  "id": "prod_abc123",
  "name": "Laptop Stand",
  "price_gbp": 29.99,
  "in_stock": true,
  "tags": ["accessories", "ergonomics"],
  "dimensions": {
    "width_cm": 25,
    "depth_cm": 20,
    "height_cm": 12
  }
}

Inferred JSON Schema draft-07:

{
  "type": "object",
  "properties": {
    "id": { "type": "string" },
    "name": { "type": "string" },
    "price_gbp": { "type": "number" },
    "in_stock": { "type": "boolean" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    },
    "dimensions": {
      "type": "object",
      "properties": {
        "width_cm": { "type": "number" },
        "depth_cm": { "type": "number" },
        "height_cm": { "type": "number" }
      },
      "required": ["width_cm", "depth_cm", "height_cm"]
    }
  },
  "required": ["id", "name", "price_gbp", "in_stock", "tags", "dimensions"]
}

What to do after inferring

The inferred schema is a starting point, not a finished product. Common refinements:

  1. Remove truly optional fields from required. Every key in the sample ends up in required. Delete the ones that the API legitimately omits sometimes.
  2. Add enum for known-value fields. If status can only be "active", "pending", or "archived", replace "type": "string" with "enum": ["active", "pending", "archived"].
  3. Add format hints. Date strings benefit from "format": "date-time"; URLs from "format": "uri". These do not enforce in all validators but document intent clearly.
  4. Merge mixed array items. The tool infers from the first array element only. If your real data has arrays with mixed shapes, merge the variants by hand using oneOf or anyOf.

Tips and notes

  • Inferred required is a starting point. Delete the ones that are genuinely optional before validating real traffic.
  • Add constraints after inference. The tool gives you types and structure; add enums, formats, minimums, and patterns yourself to make the schema strict.
  • Great for function calling. The inferred object schema drops cleanly into a tool or function parameter definition for OpenAI or Anthropic.
  • Nothing is uploaded. Inference runs entirely in your browser — safe for responses that contain PII or proprietary data.