JSON to Schema Generator
Generate a JSON Schema from sample JSON data.
POST
1 credit
/v1/json-to-schema
curl -X POST "https://devtools.toolkitapi.io/v1/json-to-schema" \
-H "Content-Type: application/json" \
-d '{"data": {"name": "Alice", "age": 30, "tags": ["dev", "ops"]}}'
import httpx
resp = httpx.post(
"https://devtools.toolkitapi.io/v1/json-to-schema",
json={"data": {"name": "Alice", "age": 30, "tags": ["dev", "ops"]}},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/json-to-schema", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({"data": {"name": "Alice", "age": 30, "tags": ["dev", "ops"]}}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"tags": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["age", "name", "tags"]
}
}
Try It Live
Live Demo
Response
Description
Generate a JSON Schema from sample JSON data.
How to Use
1
1. Send a POST request with a `data` field containing a sample JSON object (or an array of objects for broader type inference).
2
2. The response contains a `schema` field with the generated JSON Schema.
3
3. Use the schema for validation, documentation, or code generation.
About This Tool
JSON to Schema Generator infers a JSON Schema definition from one or more sample JSON objects. Pass a single object or an array of objects and the tool will produce a schema that describes the structure, types, and required fields.
Why Use This Tool
- API documentation — Auto-generate schemas from example payloads
- Validation bootstrapping — Create a starting schema from real data, then refine it
- Code generation — Feed the schema into TypeScript, Go, or Rust type generators
- Data catalog — Document dataset shapes from sample records
Frequently Asked Questions
Can I pass multiple samples?
Yes. Pass an array of objects as `data` and the generator will merge them into a single schema that covers all observed types and fields.
What JSON Schema draft does it produce?
The generator uses the `genson` library which produces JSON Schema compatible with Draft 4+.
Start using JSON to Schema Generator now
Get your free API key and make your first request in under a minute.