JSON Schema Generator — Generate JSON Schema from JSON Online [2026]
Paste JSON and get a valid JSON Schema instantly. Detects types, required fields, nested objects and arrays. Perfect for API validation, OpenAI function calling, and AI structured output. Free online tool.
What is JSON Schema Generator?
How to Use JSON Schema Generator
Paste your JSON into the left panel — the tool instantly generates a JSON Schema in the right panel. Toggle "Mark all fields required" to include or exclude the required array. Toggle "Include $schema" to add the draft-07 schema URI. Click "Copy Schema" to copy the output. Use it directly in OpenAI function calling definitions, API validators, or Gemma 4 structured output configurations.
How JSON Schema Generator Works
Common Use Cases
- Creating OpenAI function calling schemas from example API responses
- Defining structured output schemas for Gemma 4, Claude, and other AI models
- Generating validation schemas for REST API request/response bodies
- Building OpenAPI/Swagger specification components from example data
- Creating form validation rules from existing JSON configuration files
- Documenting API contracts by generating schemas from sample payloads
Frequently Asked Questions
Which JSON Schema draft does this tool generate?▼
The tool generates JSON Schema draft-07 (http://json-schema.org/draft-07/schema#), which is the most widely supported version. It works with OpenAI function calling, most validators (ajv, jsonschema), and API documentation tools like Swagger/OpenAPI 3.0.
Can I use the output for OpenAI function calling?▼
Yes — the generated schema is directly compatible with OpenAI function calling parameter definitions. Copy the generated schema, remove the $schema URI if needed, and paste it as the parameters field in your function definition. The same schema works for Anthropic Claude tool use and Google Gemini function declarations.
How does the tool handle nested objects and arrays?▼
Nested objects are processed recursively — each nested object gets its own properties map and type definitions. Arrays are handled by examining the first element to infer the items schema. Arrays of objects produce a complete nested object schema. Deeply nested structures (objects within arrays within objects) are fully supported.
How are required fields determined?▼
When "Mark all fields required" is enabled (the default), every property at every level is included in the required array. This is the safest default for API validation. You can toggle this off if you need optional fields, then manually edit the required arrays for your specific use case.
What happens with arrays containing different types?▼
If an array contains elements of different types (mixed arrays like [1, "hello", true]), the tool uses the first element to determine the items schema. For production use with mixed-type arrays, you may need to manually adjust the schema to use oneOf or anyOf. Most AI function calling schemas expect uniform arrays.
What is the difference between JSON Schema and TypeScript types?▼
JSON Schema validates runtime JSON data and is language-agnostic — it works in any language and is the standard for API contracts and AI function calling. TypeScript types are compile-time only and exist only in the TypeScript ecosystem. For AI applications, JSON Schema is required because it can be sent as data to the model, while TypeScript types cannot.
Related Tools
AI VRAM Calculator
Calculate VRAM needed to run AI models locally. Select model size, quantization ...
LLM Pricing Calculator
Compare AI API costs across providers. Enter token counts to see pricing for Ope...
AI Token Counter
Paste text → instantly count tokens for GPT-4o, Claude, Gemini & more. See API c...
JSON Escape
Free JSON escape tool — paste any string → get properly escaped JSON output in o...
Explore More Free Tools
Discover more tools from our network — all free, browser-based, and privacy-first.