Generador de Esquema JSON
Genera un Esquema JSON (Borrador 2020-12) a partir de un documento JSON de ejemplo. Detección de formato inteligente.
Respuesta rápida: Generador de Esquema JSON: genera un esquema JSON (borrador 2020-12) a partir de un documento JSON de ejemplo. Detección inteligente de formato. Funciona íntegramente en el navegador, gratis y sin registro.
Última actualización
Bueno saber
A schema generated from a single example is a starting point, not a finished contract. Because the tool sees one document, it marks every property as required and pins each type exactly. That is usually too strict for real APIs, where fields come and go and some values are legitimately null. Expect to prune the required array and widen types before you ship the schema to production validation.
The format detection is genuinely useful: strings that look like ISO 8601 timestamps, email addresses, or URIs get the matching format keyword, which downstream validators such as Ajv can enforce. Draft 2020-12 is the output dialect, so it plays nicely with modern tooling, but note that some format checks are opt-in and must be enabled in your validator's configuration.
If your data varies across records, generate a schema from a few representative samples and merge them by taking the union of properties and the intersection of required keys. For editing the resulting document, pretty-printing it, or converting between formats, pair this with the JSON formatter. Reserve heavyweight schema-inference libraries for when you need enums, pattern constraints, or multi-file references.
Preguntas frecuentes
- ¿Por qué mi esquema es demasiado estricto?
- Inferimos de un solo ejemplo, por lo que cada campo es requerido y los tipos son exactos. Relaja el esquema eliminando claves del <code>required</code> array o usando <code>type: ["string", "null"]</code> para campos anulables.
- ¿Qué borrador es la salida?
- JSON Schema Draft 2020-12, la última versión estable. Es compatible con todos los validadores modernos (Ajv, JSON Schema Validator, etc.).
- ¿Detectará correos electrónicos, URLs y fechas?
- Sí — los valores de cadena que coinciden con patrones de correo electrónico, fecha y hora (ISO 8601) y URL reciben la correspondiente anotación de <code>format</code>.
- ¿Mis archivos JSON se suben?
- No — la inferencia se ejecuta completamente en tu navegador.
- ¿Cómo infiero a partir de múltiples muestras?
- Genera un esquema a partir de cada muestra, luego combina manualmente (o usa una herramienta como <code>quicktype</code>) — tomar la unión de propiedades y la intersección de claves requeridas da un esquema que se ajusta a todas las muestras.