JSON Schema Generator
Updated Free mock REST & WebSocket APIs
Paste sample JSON to generate a JSON Schema instantly — types, nested objects, arrays, required fields and string formats inferred for you. One click turns it into an OpenAI structured-outputs response_format or a Claude tool input_schema.
🔒 Generated in your browser — your JSON is never uploaded.
How to generate a JSON Schema from JSON
- Paste a sample JSON document (or an array of several samples) or open a .json file.
- Choose the output: plain JSON Schema (draft 2020-12 or draft-07), OpenAI structured output, or Claude tool definition.
- Adjust required fields, format detection and additionalProperties, then copy or download the result.
How the schema is inferred
| Sample value | Schema |
|---|---|
42 | {"type": "integer"} |
4.5 (or 42 and 4.5 in different items) | {"type": "number"} |
"2026-10-18T09:30:00Z" | {"type": "string", "format": "date-time"} |
"ada@example.com" | {"type": "string", "format": "email"} |
null | {"type": "null"} |
| Array of objects | Items merged; a key is required only if every item has it |
JSON Schema for LLM structured outputs
OpenAI's Structured Outputs (strict: true) accept a subset of JSON Schema: every property must be listed in required, objects need additionalProperties: false, and optional fields are expressed as a union with null. The “OpenAI structured output” option applies these rules for you:
{
"type": "json_schema",
"json_schema": {
"name": "Invoice",
"strict": true,
"schema": {
"type": "object",
"properties": {
"invoice_id": { "type": "string" },
"discount": { "type": ["number", "null"] }
},
"required": ["invoice_id", "discount"],
"additionalProperties": false
}
}
}For Claude, put the schema in a tool's input_schema (or use structured outputs with output_config.format); add strict: true on the tool to guarantee schema-valid arguments.
Tips
- Give several samples (an array, with the “several samples” option) so optional fields and nullable values are detected correctly.
- Add
descriptionfields by hand after generating — models use them as instructions. - Need TypeScript or Zod instead? Use JSON to TypeScript or JSON to Zod.
Related tools
Frequently asked questions
Is my JSON uploaded?
No. The schema is generated in your browser; your JSON never leaves your device.
Which JSON Schema draft should I use?
Draft 2020-12 is current and supported by Ajv, OpenAPI 3.1 and most validators. Choose draft-07 for older tools that don't understand 2020-12.
Why does the OpenAI version make fields nullable?
Strict structured outputs require every property to be required. A field that's missing in some samples is therefore kept required but allowed to be null, which is how OpenAI recommends expressing optional values.
Can it detect enums?
Not automatically — a sample can't tell an enum from free text. Replace a string type with "enum": ["paid", "refunded"] when the values are fixed.
Your business here? Sponsor this tool from $16/week. See placements