JSON to Schema Generator
Paste any JSON and get a complete JSON Schema definition automatically. Detects types, string formats, nested objects, and arrays. Then refine with constraints, descriptions, and enum values.
Free JSON to JSON Schema Generator
Writing JSON Schema by hand is tedious and error-prone, especially for complex data structures with deeply nested objects and mixed-type arrays. Our generator takes the opposite approach: start with a JSON example and let the tool infer the schema for you. Paste any JSON document and get a complete, valid JSON Schema in seconds.
How Schema Generation Works
The generator analyzes your JSON data and recursively builds a schema that describes its structure. For each value, it determines:
- Type inference. Strings, numbers (integer vs. float), booleans, null, objects, and arrays are detected automatically. Numbers that are whole values are typed as "integer" for stricter validation.
- String format detection. The generator identifies common string formats: email addresses become
format: "email", URLs becomeformat: "uri", ISO dates becomeformat: "date-time", and UUIDs becomeformat: "uuid". This adds validation beyond just "is it a string?" - Nested object handling. Objects are processed recursively, with each nested object getting its own schema definition with properly typed properties and required fields.
- Array analysis. Arrays are analyzed for consistency. If all items are the same type, the schema uses a single item schema. If items are objects, all objects are merged to capture the complete set of properties. For arrays with mixed types, the schema uses
oneOfto represent each possible type. - Required fields. By default, all properties present in your example are marked as required (since they were present in the sample data). You can toggle individual fields to optional in the refinement panel.
Refining the Generated Schema
The generated schema is a starting point. Real-world schemas usually need additional constraints. The refinement panel below the output lets you customize each field without editing JSON directly:
- Required/Optional toggle. Mark which fields must be present and which are optional. By default, all detected fields are required — uncheck fields that are truly optional.
- Type override. The generator infers the most likely type, but you may want to change it. For example, a field that's always a string in your sample might need to accept null as well.
- Descriptions. Add human-readable descriptions to each field. These descriptions become part of the schema and serve as documentation for developers consuming your API or data format.
- Numeric constraints. Add minimum and maximum values for number and integer fields. Useful for age ranges, prices, quantities, and other bounded values.
- String constraints. Set minLength and maxLength for string fields. Add enum values for fields that should only accept specific values (like status fields or role names).
Best Practices for Generating Schemas
- Use a representative example. The quality of the generated schema depends on the completeness of your sample data. Include all possible fields, even optional ones, so the generator can capture the full structure.
- Include edge cases in arrays. If your array can contain items with different structures, include examples of each variant so the generator correctly uses
oneOf. - Review required fields carefully. Just because a field is present in your example doesn't mean it should be required in the schema. Think about which fields callers must always provide vs. which are optional.
- Add descriptions. A schema without descriptions is a missed opportunity. Future developers (including future you) will benefit from clear explanations of what each field represents.
- Validate after generating. After generating and refining, copy the schema into our JSON Schema Validator and test it against several real-world data samples to ensure it works correctly.
Output Draft Support
The generator outputs valid JSON Schema in whichever draft you select. The default is Draft 2020-12 (the latest stable version). If your toolchain requires an older draft, select it from the dropdown — the generator adjusts the $schema URI and uses syntax compatible with the chosen draft.
Related Tools
After generating your schema, use our JSON Schema Validator to test it against different JSON payloads. For structured data markup (Schema.org / JSON-LD), see our JSON-LD Generator.