{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Root",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"active": {
"type": "boolean"
},
"joined": {
"type": "string",
"format": "date-time"
},
"website": {
"type": "string",
"format": "uri"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
},
"zip": {
"type": "string"
}
},
"required": [
"street",
"city",
"zip"
],
"additionalProperties": false
},
"scores": {
"type": "array",
"items": {
"type": [
"number",
"integer"
]
}
}
},
"required": [
"id",
"name",
"email",
"active",
"joined",
"website",
"tags",
"address",
"scores"
],
"additionalProperties": false
}Notes
- Detected formats:
date-time, date, time, email, uri, uuid, ipv4. - Array merge mode unifies item schemas across all elements (handles mixed types as
[type1, type2]). - Generated schema is compatible with Ajv and the JSON Schema Validator tool — paste it there to test.
About JSON → JSON Schema
JSON Schema Generator infers a JSON Schema from a sample document. Types and structure are inferred from the input; recognised string patterns are tagged with `format` (`email`, `date-time`, `uri`, `uuid`, `ipv4`); fields present in the sample are marked as `required`. The output is a Draft-07 JSON Schema by default — the version most validators and OpenAPI tooling consume — with options to target older or newer drafts.
Reach for it whenever you have a JSON sample and need a schema to validate against, generate types from, or document the API: bootstrap a contract for an undocumented endpoint, derive an OpenAPI component from a real response, build a fixture validator for a CI test. JSON Schema Validator is the consumer of the generated schema; JSON to Code is the alternative output (source code instead of a schema document). For the inverse direction — generate a sample that conforms to an existing schema — use JSON Mock Generator.
Examples
{"id": 42, "email": "ada@example.com", "created_at": "2024-01-15T10:30:00Z"}{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "email", "created_at"],
"properties": {
"id": { "type": "integer" },
"email": { "type": "string", "format": "email" },
"created_at": { "type": "string", "format": "date-time" }
}
}All three fields marked required because they appear in the sample. `email` and `date-time` formats detected from value patterns.
Frequently asked questions
How is this different from JSON to Code?
Both infer a type from a JSON sample, but the outputs differ. JSON to Code emits source code in a programming language. JSON Schema Generator emits a JSON Schema document — useful as input to a validator, OpenAPI spec, or schema-aware code generator in any language.
Why are all fields marked required?
Because they are present in the sample, and the generator has no way to know which are optional. Feed multiple samples through, then hand-edit the schema to mark fields as optional, or pass several documents and the tool will mark fields as required only if they appear in every sample.
Which formats are detected?
`email`, `date-time`, `date`, `time`, `uri`, `uuid`, `ipv4`, and `ipv6` from value patterns. Anything else is left as a plain `string`. You can edit the generated schema to add more nuanced constraints (`minLength`, `pattern`, `enum`).
Can I use the result with the validator on this site?
Yes. Paste the generated schema and a document into JSON Schema Validator to check conformance. The two tools share the same Draft-07 (and newer) support.
