About this tool
Writing a schema by hand is slow. Paste sample data and get a starting schema with types, nested properties, array items and required fields already filled in. All items of an array are merged, so a field becomes required only if every sample has it.
How to use it
- Paste one or more samples as a JSON array.
- Choose the draft and whether to mark required fields and allow extra ones.
- Copy the schema, then add formats, limits and enums for your real data.
Example
[{"id":1,"name":"Alex"},{"id":2,"name":"Riya","email":"riya@example.com"}]{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
}Questions
- Is the generated schema ready to use?
- It's a starting point. It describes only the samples you gave, so add things the samples can't show, such as formats, string lengths, number ranges and allowed values.
- How are integers and decimals handled?
- Whole numbers become "integer". If a field has both whole and decimal numbers, it becomes "number".
- Can I test data against the result?
- Yes. Paste the schema into the JSON Schema Validator with your data to check it.