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:
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.
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.
Related Tools
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSON Schema Validator
Validate a JSON payload against a JSON Schema online. Supports Draft 2020-12, format validation (date-time, uuid, email, uri), and shows errors by JSON pointer path. 100% local — nothing is uploaded.
JSONPath Tester
Test JSONPath expressions against sample JSON online. Get instant, highlighted results for queries like $.store.book[*].author.
JSON Diff
Compare two JSON documents structurally and see added, removed, and changed values by path. Handles nested objects, arrays, and type changes.
JSON Escape
Escape strings for use inside JSON, or unescape JSON string literals back to plain text. Handles quotes, newlines, tabs, and Unicode.