JSON to JSON Schema
Try it interactively →POST /api/json-to-jsonschemaGenerate a JSON Schema (Draft 2020-12) from sample JSON. Infers types, required fields, and array element shapes. Useful for typing APIs from real responses.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| samples* | string | — | JSON array of sample documents. Pass `[doc]` for a single sample, `[doc1, doc2,.]` to union multiple shapes. |
| noRequired | boolean | false | Emit no `required` arrays — every property becomes optional. Use when samples are sparse. |
Response
Modes: json. Cache: yes (24h TTL).
Code samples
Built from the user-shape example.
curl -X POST https://api.xtract.bot/api/json-to-jsonschema \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"samples": "[{\"id\":1,\"name\":\"Ada\",\"email\":\"ada@example.com\"},{\"id\":2,\"name\":\"Grace\"}]",
"noRequired": false
}'