webdev_json_schema_generator
Generate a JSON Schema (Draft-07) from a sample JSON document by analyzing structure, types, and properties. Use this to create schemas from existing data.
Instructions
JSON Schema Generator (Infer Draft-07 From Sample). Infer a JSON Schema (Draft-07, $schema fixed to http://json-schema.org/draft-07/schema#) from one sample JSON document, walking the value to emit types, properties, required, array items (oneOf for mixed element types), and optional format/pattern detection (email, date-time, uri, uuid, ipv4, ipv6) and per-property examples. Use this to draft a schema from data you already have; use webdev_json_schema_validator instead to check an existing instance against a schema you already have. Runs locally on the input you provide: read-only, non-destructive, contacts no external service, and is rate-limited. Returns the inferred schema as both an object and a 2-space-indented JSON string, an isValid flag, parse errors, and shape statistics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | Yes | Sample JSON document to infer the schema from, as a string of raw JSON (also accepted as input). | |
| title | No | Value placed in the generated schema top-level title field. | Generated Schema |
| description | No | Value placed in the generated schema top-level description field. | Schema generated from JSON data |
| additionalProperties | No | Sets additionalProperties on every generated object schema; false forbids unlisted keys. | |
| detectFormats | No | Detect string format (email, date-time, uri, uuid, ipv4, ipv6) from sample values. | |
| requireAll | No | List every key in required; when false only non-null keys are required. | |
| includeExamples | No | Add an examples array carrying each sampled value to the generated schemas. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| isValid | No | Whether the input parsed as JSON and a schema was produced. | |
| schema | No | The inferred JSON Schema as an object (Draft-07), or null when the input is empty or invalid. | |
| schemaJson | No | The inferred schema serialized as a 2-space-indented JSON string (empty string on failure). | |
| errors | No | Parse/validation errors; empty on success. | |
| stats | No | Shape statistics computed from the generated schema. |