DevKits

JSON Schema Generator (OpenAI, Anthropic, Draft 2020-12)

Generate a JSON Schema from a sample JSON — output as standard Draft 2020-12, OpenAI function calling schema, or Anthropic tool_use schema. Powers LLM structured output pipelines.

Last updated:

Comments

Infer a JSON Schema from a sample JSON payload. Choose from Draft 2020-12 (standard), OpenAI function calling schema, or Anthropic tool_use schema output. Powers LLM structured output pipelines. 100% local.

306 chars · 13 lines
{
"$schema":"https://json-schema.org/draft/2020-12/schema"
"title":"Root"
"type":"object"
"properties":{
"id":{
"type":"string"
"format":"uuid"
}
"email":{
"type":"string"
}
"profile":{
"type":"object"
"properties":{ 5 keys }
"required":[ 5 items ]
"additionalProperties":false
}
"roles":{
"type":"array"
"items":{ 1 key }
}
"lastLoginAt":{
"type":"null"
}
}
"required":[
0:"id"
1:"email"
2:"profile"
3:"roles"
4:"lastLoginAt"
]
"additionalProperties":false
}

Tips & Best Practices

  • ▸The generated schema is a starting point — refine required fields, add descriptions, and tighten types before shipping.
  • ▸OpenAI function-calling schemas require additionalProperties: false and every field in required for strict mode; the tool emits both automatically.
  • ▸Provide more diverse sample data (multiple examples with different fields) for a schema that generalizes better.

Frequently Asked Questions

What is JSON Schema used for with LLMs?

JSON Schema is how you tell an LLM the exact shape of the output you want. OpenAI structured output (response_format: json_schema), OpenAI function calling, Anthropic tool_use, and most agent frameworks all require a schema to enforce valid output. Handwriting these schemas is tedious — this tool infers one from a sample.

Why does OpenAI mode force all fields to be required?

OpenAI's strict structured output requires every property in required and additionalProperties: false. Fields that are 'optional' in practice must be modeled as {"type": ["string", "null"]} instead. Turning off Strict mode produces a more permissive but non-strict schema.

How are strings, dates, and UUIDs detected?

The generator recognizes ISO 8601 date-time, plain YYYY-MM-DD dates, UUIDs, and http/https URIs, and annotates them with the appropriate JSON Schema format keyword. Ambiguous strings stay as plain type: string to avoid false positives.

How are arrays with mixed element types handled?

Element types are merged. If items are structurally similar (all objects), their fields are unioned and only fields present in every element become required. Truly heterogeneous arrays fall back to anyOf.

Try Next

JSON Repair

Automatically fix invalid JSON — trailing commas, single quotes, unquoted keys, comments, markdown code fences, and Python-style True/False/None. Purpose-built for LLM output. 100% local.

Related Tools

Reference & Guides