About JSON Schema Generator
JSON Schema is a standard way to describe the structure of JSON: which properties exist, what type each one has and which are required. It is used to validate API requests, generate forms and documentation, and check configuration files.
Paste a sample JSON document and this tool infers a draft 2020-12 schema. Objects become type object with properties and a required list, arrays use the type of their first element, whole numbers become integer, other numbers become number, and strings and booleans keep their types.
How to use JSON Schema Generator
- Paste a representative JSON sample into the input box.
- Click Run Tool to generate the schema.
- Review it, then add rules such as minLength, enum, format or optional properties by hand.
Example
Input
{"id":1,"name":"Aman","email":"aman@example.com","score":82.5,"tags":["php","wp"],"active":true,"address":{"city":"Ludhiana"}}Output
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"score": {
"type": "number"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"active": {
"type": "boolean"
},
"address": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
},
"required": [
"id",
"name",
"email",
"score",
"tags",
"active",
"address"
]
}Common uses
- Documenting an API response or request body.
- Creating a starting point for request validation in your back end.
- Checking the types of the fields in a data file.
Privacy and safety
This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.
Frequently asked questions
Why are all properties required?
A single sample cannot show which fields are optional, so every key is marked required. Edit the required list to match your real rules.
Does it detect formats such as email or date?
No. Strings are typed as string only. Add a format keyword yourself where it makes sense.
What about arrays with mixed items?
The schema is based on the first item. If your arrays can contain different shapes, change items to use oneOf.