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:
- Remove truly optional fields from
required. Every key in the sample ends up inrequired. Delete the ones that the API legitimately omits sometimes. - Add
enumfor known-value fields. Ifstatuscan only be"active","pending", or"archived", replace"type": "string"with"enum": ["active", "pending", "archived"]. - Add
formathints. Date strings benefit from"format": "date-time"; URLs from"format": "uri". These do not enforce in all validators but document intent clearly. - 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
oneOforanyOf.
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.