JSON Schema Builder - Visual Schema Generator

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {}
}

How to Use the JSON Schema Builder

Click Add Field to add properties to your schema. For each field, set the name, type, and whether it is required. You can add nested objects by selecting the “object” type and then adding child fields within it. The tool generates a valid JSON Schema (draft-07) in real time that you can copy and use directly in your API calls or validation pipelines.

Why JSON Schema Matters for AI Structured Outputs

When you call an AI model’s API, the response is typically unstructured text. This is fine for chat interfaces, but problematic when you need to parse the output programmatically. JSON Schema solves this by telling the model exactly what structure to return.

All major AI providers now support structured outputs through JSON Schema. You provide a schema in your API request, and the model constrains its output to match that schema exactly. This eliminates the need for fragile regex parsing or retry loops when the model returns unexpected formats.

Supported Field Types

The builder supports all standard JSON Schema types that AI models can produce:

TypeDescriptionExample Value
stringText values”hello world”
numberDecimal numbers3.14
integerWhole numbers42
booleanTrue or falsetrue
arrayLists of items[1, 2, 3]
objectNested structures{"key": "value"}
enumFixed set of values”small”, “medium”, “large”

Building Schemas for Common Use Cases

For data extraction tasks, create an object with string fields for each piece of data you want extracted. For classification, use an enum field with the allowed categories. For list generation, define an array field with an object item type containing the properties each list item should have.

JSON Schema vs. Freeform Prompting

Without a schema, you rely on prompt instructions like “return your answer as JSON with fields name and age.” This approach is unreliable because models may add extra fields, change field names, or wrap the JSON in markdown code blocks. With JSON Schema, the output is guaranteed to match your specification on every call.

The tradeoff is that schemas add tokens to your request. Use the Token Counter to measure how much your schema costs per request, especially for high-volume applications. A typical schema with five to ten fields adds 200 to 400 tokens to your prompt.

Exporting and Using Your Schema

Copy the generated schema and paste it into your API configuration. For OpenAI, add it to the response_format parameter. For Anthropic’s Claude, use it with the tool use feature. For Google’s Gemini, include it in the generation configuration. You can also use the schema for input validation with libraries like Ajv (JavaScript) or jsonschema (Python).

If you need to convert your schema between formats, the JSON / YAML / TOML Converter can transform it to YAML for use in OpenAPI specs or configuration files.

Frequently Asked Questions

What is JSON Schema used for in AI?

JSON Schema defines the exact structure that AI model responses must follow. OpenAI, Anthropic, and Google all support JSON Schema in their APIs to guarantee structured outputs, ensuring the model returns data in your expected format with the correct field names and types.

Which JSON Schema draft should I use?

Draft-07 is the most widely supported version across AI APIs and validation libraries. OpenAI and Anthropic both accept draft-07 schemas for structured outputs. This tool generates draft-07 by default.

Can I nest objects and arrays in JSON Schema?

Yes. JSON Schema supports deeply nested structures including objects within objects, arrays of objects, and arrays of primitives. This builder lets you visually create nested schemas by adding object or array type fields and defining their child properties.

How do I make fields required in JSON Schema?

In JSON Schema, required fields are listed in a 'required' array at the object level. In this visual builder, simply toggle the required switch next to any field. The generated schema will include the correct required array automatically.