JSON to OpenAPI 3.0 Schema Component — Free Online Tool
Convert JSON to an OpenAPI 3.0 schema component (components/schemas section) with correct types, required fields, and nested $ref definitions using AI. Free, no sign-up.
JSON to OpenAPI 3.0 Schema Component — Free Online Tool
About JSON to OpenAPI 3.0 Schema Component — Free Online Tool
JSON to OpenAPI Schema converts a JSON sample into a valid OpenAPI 3.0 component schema definition, inferring types, required fields, and nested object structures automatically. Developers use it to bootstrap API documentation, generate reusable schema components for OpenAPI specs, and avoid hand-writing verbose YAML or JSON Schema by hand.
JSON Type to OpenAPI 3.0 Type Mapping
| JSON Value Example | JSON Type | OpenAPI type | OpenAPI format |
|---|---|---|---|
| "hello" | string | string | (none) |
| "2024-01-15T10:00:00Z" | string (ISO 8601) | string | date-time |
| "2024-01-15" | string (date) | string | date |
| 42 | integer | integer | int32 |
| 9007199254740991 | large integer | integer | int64 |
| 3.14 | number | number | float |
| 1.7976931348623157e+308 | large number | number | double |
| true / false | boolean | boolean | (none) |
| null | null | (none) | nullable: true added to parent |
| [1, 2, 3] | array | array | items: type inferred from elements |
| {"key": "val"} | object | object | properties generated recursively |
OpenAPI Schema vs Alternative Description Formats
| Feature | OpenAPI 3.0 Schema | JSON Schema Draft-07 | JSON Schema Draft 2020-12 | Swagger 2.0 (OAS2) |
|---|---|---|---|---|
| Spec home | openapis.org | json-schema.org | json-schema.org | swagger.io |
| Supported in | OAS 3.x API specs | Standalone validation | Standalone validation | OAS 2.x API specs |
| nullable fields | nullable: true | type: ["T","null"] | type array or oneOf | x-nullable extension |
| Discriminator / oneOf | Native support | oneOf only | oneOf/anyOf/allOf | Limited |
| readOnly / writeOnly | Both supported | readOnly only | Both supported | readOnly only |
| $ref style | #/components/schemas/ | #/definitions/ | $defs/ | #/definitions/ |
| Format keyword | Supported | Supported | Supported | Supported |
| example keyword | example (singular) | examples (plural) | examples (plural) | example (singular) |
Frequently Asked Questions
How do I convert JSON to OpenAPI schema?
Paste your JSON sample into a JSON to OpenAPI schema converter tool and it will infer each field's OpenAPI type, mark all present keys as required, and wrap the output in a valid components/schemas object. You can then paste the generated YAML or JSON directly into your openapi.yaml file under the components.schemas section. For nested objects, the tool recursively generates $ref or inline schema definitions.
What is the difference between JSON Schema and OpenAPI schema?
OpenAPI 3.0 schema is a strict subset of JSON Schema Draft-07 with several extensions and restrictions. OpenAPI adds keywords like nullable, discriminator, readOnly, writeOnly, and example, while removing some JSON Schema keywords like $schema, id, and patternProperties. A valid OpenAPI schema is not always a valid standalone JSON Schema and vice versa.
Does OpenAPI 3.0 support nullable fields?
Yes. In OpenAPI 3.0 you mark a field as nullable by adding nullable: true alongside the type, for example type: string with nullable: true. This is different from JSON Schema where null is expressed as a type union (type: ["string", "null"]). OpenAPI 3.1 aligns with JSON Schema 2020-12 and drops nullable in favor of the type array approach.
How do I reference a generated schema in my OpenAPI spec?
After generating the schema component, place it under components.schemas in your openapi.yaml, for example as components.schemas.MyObject. Then reference it anywhere in your paths using $ref: '#/components/schemas/MyObject'. This keeps your spec DRY and allows multiple endpoints to reuse the same schema definition.
Can the tool detect required fields from a JSON sample?
By default, JSON to OpenAPI converters mark every key present in the sample JSON as required, since there is no way to infer optionality from a single example. You should manually remove keys from the required array for fields that your API treats as optional. If you have multiple sample objects, some tools can detect fields absent in some samples and omit them from required automatically.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.