No Login Data Private Local Save

JSON to JSON Schema Generator - Online Infer Structure

14
0
0
0

JSON to JSON Schema Generator

Online Infer Structure — Paste your JSON and instantly generate a valid JSON Schema

Draft 7 / 2020-12
JSON Schema Output

Frequently Asked Questions

JSON Schema is a declarative format for describing the structure, constraints, and validation rules of JSON data. It acts as a contract between data producers and consumers, ensuring data integrity across APIs, configuration files, and data pipelines. Common use cases include API request/response validation, form validation, automated documentation generation (like Swagger/OpenAPI), and IDE autocomplete support.

When enabled, the tool analyzes your JSON to determine which properties should be marked as required. For a single object, all properties are considered required. For arrays of objects, only properties present in every object are marked required. This helps downstream validators enforce mandatory fields accurately.

When "Detect Formats" is enabled, the tool recognizes: date (YYYY-MM-DD), date-time (ISO 8601), email, uri (http/https), uuid, ipv4, ipv6, hostname, and color hex codes. These format annotations help validators enforce semantic correctness beyond basic type checking.

This tool supports Draft 4, Draft 7, and Draft 2020-12. Draft 7 is the most widely compatible version and is selected by default. Draft 2020-12 introduces modern features like $dynamicAnchor and unevaluatedProperties, while Draft 4 remains in use for legacy systems.

For arrays, the tool examines all elements to determine the items schema. If all elements share the same type, a single type is used. For arrays with mixed types, anyOf is generated to cover all observed types. For arrays of objects, properties are intelligently merged across all elements, with required fields computed based on consistent presence.

Absolutely. The generated schema is compatible with all major JSON Schema validators including Ajv (JavaScript), jsonschema (Python), everit-org/json-schema (Java), gojsonschema (Go), and json-schema (Ruby). You can directly use it in OpenAPI/Swagger specifications, CI/CD pipelines, and data validation frameworks.

When "Handle Null Types" is enabled, properties with null values generate a type array like ["string", "null"], indicating the field can be either the observed type or null. This is crucial for APIs where fields are optional or nullable. If disabled, null values are treated as their own "type": "null" without merging.

The tool checks whether all numeric values are integers (no decimal component). If every number in the input is a whole number, the schema uses "type": "integer". If any number contains a fractional part, "type": "number" is used instead. This ensures your schema accurately constrains numeric formats.