Free tools for developers

JSON Schema Generator

Paste your JSON data and get a valid JSON Schema instantly. Useful for API validation, documentation, and form generation.


What is JSON Schema?

JSON Schema is a vocabulary that allows you to describe the structure and validation rules for JSON data. It defines what properties an object should have, what types those properties should be, which properties are required, and what constraints apply to the values. JSON Schema is used for API documentation, request and response validation, form generation, and code generation.

A JSON Schema document is itself a JSON object. It uses keywords like type, properties, required, minimum, and maximum to describe the expected structure of the data. When you validate a JSON document against a schema you get a clear list of any violations which makes debugging API integrations much faster.

How This Tool Works

This tool takes a sample JSON document and infers a JSON Schema from it. It detects the type of each value, identifies nested objects and arrays, and generates a schema that would validate the input document. The output follows the JSON Schema Draft 7 specification which is widely supported by validation libraries in all major programming languages.

How to Use This Tool

  1. Paste a sample JSON document into the left input box.
  2. Click Generate Schema to create the JSON Schema.
  3. Review the generated schema and adjust required fields as needed.
  4. Click Copy Schema to copy it to your clipboard.

Using JSON Schema for API Validation

In .NET use the JsonSchema.Net package to validate requests against a schema. In JavaScript use the ajv library. In Python use jsonschema. In Java use the json-schema-validator library. All of these accept a JSON Schema document and a JSON value and return validation errors if the value does not match the schema.


Frequently Asked Questions

Which JSON Schema version does this generate?

This tool generates JSON Schema Draft 7 which is the most widely supported version. Draft 7 is supported by ajv, jsonschema, Json.NET, and most other validation libraries. Newer drafts like 2019-09 and 2020-12 add features but have less library support.

Are all properties marked as required?

Yes. The generated schema marks all detected properties as required based on the sample input. You should review the schema and remove properties from the required array that are actually optional in your API.

Is my JSON data safe?

Yes. Everything runs in your browser. Your JSON data is never sent to any server.