Generar esquema JSON
JSON Schema Generator automatically infers standard JSON Schema (Draft 2020-12) specifications from one or more sample JSON payloads. It features configurable required-field heuristics, type widening across heterogeneous samples, automatic format detection (email, date-time, uuid, uri), enum discovery, and live document validation against the inferred schema on the same page.
La interfaz de esta herramienta está en inglés.
✓Round-Trip Validation Test
Validate candidate JSON documents against the generated schema in real time.
La guía de abajo solo está disponible en inglés.
How does JSON Schema Generator work?
Manually authoring JSON Schema definitions is repetitive, verbose, and error-prone. The ToolsByUs Schema Inference engine automates this by performing multi-pass structural aggregation across your input samples:
- Type Inference & Widening: Recursively examines data values. When differing scalar types are observed across samples for the same key (e.g. integer and string), type widening produces an array of allowed types
type: ["integer", "string"]rather than rejecting valid variations. - Required Field Heuristics: Computes frequency ratios. Properties present across 100% of analyzed sample records are cataloged in the
requiredconstraint array. - Format & Semantic Matching: Matches string fields against RFC standards for
date-time(ISO 8601),email(RFC 5322),uuid(RFC 4122/9562), anduri(RFC 3986). - Enum Extraction: Detects repetitive low-cardinality values below a configurable threshold (e.g. status fields) and generates strict
enumsets.
Most importantly, the generator includes an interactive Round-Trip Validator: you can paste any candidate payload and immediately test it against the generated schema to verify conformance.
Sample Payload Input
{"id": "usr_101", "email": "dev@test.org", "active": true}Example output
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["id", "email", "active"],
"properties": {
"id": { "type": "string" },
"email": { "type": "string", "format": "email" },
"active": { "type": "boolean" }
}
}What options and edge cases does JSON Schema Generator support?
| Parameter | Type | Default | Behaviour & edge cases |
|---|---|---|---|
| inferRequired | Boolean | true | Automatically tags properties that appear in every provided sample as required. |
| typeWidening | Boolean | true | Allows fields with multiple observed types to support any of those types rather than forcing one. |
| detectFormats | Boolean | true | Inspects string patterns for RFC formats: email, date-time, uuid, and uri. |
| enumThreshold | Integer | 4 | Maximum unique value count to classify a string/number property as a fixed enum set. |
| Schema Draft | Standard | Draft 2020-12 | Emits modern, fully compliant JSON Schema specification draft 2020-12. |
Frequently asked questions
What version of JSON Schema does this tool generate?
This tool outputs JSON Schema Draft 2020-12, the latest stable specification recommended by the JSON Schema organization. It is compatible with modern validation libraries across Python, Node.js, Go, Rust, and Java.
Can I supply multiple sample documents?
Yes! You can paste either a single JSON object or a JSON array of multiple objects. The generator aggregates property shapes across all samples to produce comprehensive schemas with union types and accurate required field heuristics.
How does the live validation work?
The lower pane runs a real-time schema validator against whatever schema is currently generated. As you modify sample data or options above, the test document is immediately validated with exact violation paths and keywords displayed.
Is my sample schema or data transmitted to a server?
No. All schema inference and validation execute 100% locally in your browser with zero network requests, preserving complete privacy for proprietary schemas and production logs.
Why is a field marked required when my API treats it as optional?
Because inference can only see the samples you gave it, and a property present in every sample is assumed to be required. Paste an array of documents that includes the cases where the field is genuinely absent and it drops out of the required list automatically — that is the fastest way to teach the generator which fields are optional.
Can I get TypeScript types instead of a schema?
Yes, from a different tool: the JSON to TypeScript converter takes the same sample document and emits interfaces directly. A schema is the better artefact when you want runtime validation across several languages; generated types are better when the only consumer is a TypeScript codebase and the check happens at compile time.