JSON Schema Generator (Infer from Sample)
Paste a sample JSON document and get a JSON Schema describing its structure, types, nesting, and required properties. The fastest way to bootstrap request validation, API contracts, or LLM structured-output schemas.
How to use
- Paste a representative sample of your JSON data.
- Click Run to generate the inferred schema.
- Review and tighten the schema, inference can only see what your sample shows.
JSON Schema is the standard vocabulary for describing the shape of JSON data: which properties exist, their types, which are required, and what constraints apply. It powers request validation in API frameworks, form generation, editor autocomplete for config files, and, increasingly, structured output enforcement for large language models, where the schema tells the model exactly what shape of JSON to produce.
Writing a schema by hand for an existing payload is tedious and error-prone, which is what inference solves: give it one representative document and it produces a schema with correct types for every field, nested object and array structures mapped, and all observed properties listed.
Understand inference's fundamental limit: it describes your sample, not your domain. If your sample happens to have an optional field present, the schema will consider it required. If a field is null in the sample, the inferred type is null rather than the string it usually holds. If an array is empty, its item type is unknown. Treat the output as a first draft, feed the most complete sample you have, then relax or tighten constraints by hand.
Inferred schemas are also excellent documentation seeds: a schema plus one example is often clearer API documentation than paragraphs of prose.
Examples
Input: {"name": "Asha", "age": 29, "active": true}
Output: {"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "integer"}, "active": {"type": "boolean"}}, "required": ["name", "age", "active"]}
Input: {"items": [{"id": 1}, {"id": 2}]}
Output: {"type": "object", "properties": {"items": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "integer"}}}}}}
Frequently asked questions
Why are all my fields marked required?
Inference can only observe your sample, every field present in it is assumed required. If some fields are optional, either provide multiple varied samples or edit the required array by hand afterwards.
Which JSON Schema draft does this produce?
Modern draft-compatible output (type/properties/required/items keywords), which validates with every mainstream library, Ajv, jsonschema for Python, and API frameworks like FastAPI.
Can I use the generated schema for LLM structured outputs?
Yes, that is one of the most common uses now. OpenAI-style structured outputs and function calling accept JSON Schema. Paste a sample of the response you want, generate the schema, and tighten enums and descriptions by hand.
How do I handle fields that are sometimes null?
If the sample shows null, the inferred type is null. Edit it to a union like {"type": ["string", "null"]} to say 'string when present, possibly null', inference cannot know this from a single null observation.
Related tools
You get 10 free AI enhancements/day on this tool. Create a free account for higher limits, run history on your last 50 runs, and a ₹10 wallet that unlocks 300+ AI models.