JSON Schema generator
freeInfer a JSON Schema (draft 2020-12 or draft-07) from any sample document.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"age": {
"type": "integer"
},
"bio": {
"type": "null"
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
},
"country": {
"type": "string"
},
"postalCode": {
"type": "string"
}
},
"required": [
"street",
"city",
"country",
"postalCode"
]
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"verified": {
"type": "boolean"
}
},
"required": [
"id",
"name",
"email",
"age",
"bio",
"address",
"tags",
"createdAt",
"verified"
]
}Infer a JSON Schema from any sample document. Walks the value once, detects primitive types (including the integer / number distinction), recognises string formats (`date-time`, `date`, `uri`, `email`, `uuid`), and computes required fields as the intersection of keys observed across array items. Choose draft 2020-12 (the latest spec) or draft-07 for compatibility with older validators.
Common use cases
- Seeding an API contract. Drop a representative response, edit the inferred schema by hand, and use it as the canonical contract for openapi-generator, ajv, or any other schema-driven tool.
- Validating incoming webhooks. Generate a schema from a known-good webhook payload, then validate every incoming request against it. Catches malformed third-party deliveries with precise error paths.
- Documenting a config file format. Use the schema as the source of truth for your config. Most IDEs (VS Code, JetBrains) can pick up `$schema` in JSON files and provide autocomplete + inline validation from it.
- Generating test data. JSON Schema is consumed by many fuzz / property-based testing tools to generate valid example values. Use the inferred schema as input.
Frequently asked
Which draft should I pick?
2020-12 is the current standard, recommended for new projects. draft-07 has the widest tool support (most validators were written against it). They're mostly compatible for inferred schemas.
Why isn't every field required?
If your input is an array of objects with varying keys, only the keys present in *every* item are marked required. For single objects, every observed key is required. This avoids false-required claims when sibling items disagree.
What's the `format` field for?
JSON Schema's format hints — `date-time`, `email`, `uri`, `uuid` — that validators use for stricter checks. The tool detects them from string content (ISO 8601, URL.parse, etc.).
How is `integer` distinguished from `number`?
If every observed value for a field is a whole number, the type is `integer`; if any are fractional, it's `number`. Consumers like ajv enforce this — `12.5` rejected if the type is `integer`.
Will it detect enums?
Not currently. Enum inference requires frequency analysis (how many distinct string values appear across siblings); this is on the roadmap.
Can I use the schema with ajv / openapi-generator / quicktype?
Yes. The output is plain JSON Schema with `$schema` set to the draft URL, so any draft-aware tool will accept it. Pair with `json-to-typescript` here for matching types.