OpenAPI to JSON Schema Converter - extract JSON Schema from OpenAPI / Swagger specs
Turns OpenAPI 3.x and Swagger 2.0 component schemas into plain JSON Schema, rewriting nullable, $ref paths and example so validators such as AJV accept it. Validate your spec first with our OpenAPI Validator.
Loading OpenAPI to JSON Schema Converter...
How to Convert OpenAPI Schemas to JSON Schema - Step by Step Guide
Extract and normalise OpenAPI component schemas to standard JSON Schema Draft 7 for use with validators, code generators, and form libraries
Paste Your OpenAPI Specification
Paste your OpenAPI 3.x or Swagger 2.0 spec in JSON or YAML. The converter reads all schemas from components/schemas (or definitions for Swagger 2.0) and converts them to JSON Schema Draft 7:
$defs documentExample: OpenAPI Schema with nullable and $ref
A User schema with OpenAPI-specific nullable and a $ref to a Profile schema:
components: schemas: User: type: object required: [id, email] properties: id: { type: integer } active: type: boolean nullable: true profile: $ref: '#/components/schemas/Profile'
Auto-Generated JSON Schema Output
Each OpenAPI schema is normalised to standard JSON Schema Draft 7. Key transformations applied:
type: boolean with nullable: true becomes "type": ["boolean", "null"]; a nullable $ref is wrapped in anyOf#/components/schemas/X → #/$defs/X to match JSON Schema's $defs conventionxml, discriminator, and externalDocs fields are stripped as they are not part of JSON Schemaexample (singular) is converted to JSON Schema examples (array)Example: Generated JSON Schema Output
The User schema above as JSON Schema Draft 7 (trimmed; the real output also carries the other schemas under $defs):
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["id", "email"], "properties": { "active": { "type": ["boolean", "null"] }, "profile": { "$ref": "#/$defs/Profile" } } }
Download and Use in Your Validation Pipeline
Download the JSON Schema file and plug it into any JSON Schema validator:
schema prop — your API models instantly become auto-rendered, validated data entry formsWhat is OpenAPI to JSON Schema Conversion?
OpenAPI schemas are based on JSON Schema but include extensions (nullable, discriminator, xml) and restrict some keywords. Validators like AJV and form generators like react-jsonschema-form expect pure JSON Schema. This converter bridges the gap by extracting components/schemas and normalising them to JSON Schema Draft 7.
The primary difference is nullable: true — OpenAPI's way of allowing null values. JSON Schema has no such keyword; it lists null as one of the allowed types instead. The converter also rewrites $ref paths from #/components/schemas/ to #/$defs/, removes OpenAPI-only fields (xml, discriminator), and converts singular example to the JSON Schema examples array.
The output schema includes a $defs block containing all converted schemas so that $ref cross-references resolve correctly. For bundled multi-schema output, a root document with $schema and $defs is generated — compatible with AJV's schema management. Validate your spec first with our OpenAPI Validator.
Common Use Cases
Runtime Request Validation
Extract JSON schemas from your OpenAPI spec and use AJV to validate incoming API requests in your Node.js server — ensuring payloads match the spec before processing. Pair with our OpenAPI to TypeScript converter for compile-time safety too.
Form Generation
Use the extracted JSON Schema with react-jsonschema-form or React Hook Form resolvers to auto-generate data entry forms directly from your API models — keeping forms and API contracts in sync. Start with our JSON to OpenAPI tool if you're building from scratch.
Frequently Asked Questions
What JSON Schema draft does the output use?
For OpenAPI 3.0 and Swagger 2.0 specs the output is JSON Schema Draft 7, and $schema is set to http://json-schema.org/draft-07/schema#. OpenAPI 3.1 schemas already are JSON Schema 2020-12, so for a 3.1 spec the output says 2020-12 instead and the schemas pass through almost untouched.
How is OpenAPI nullable handled?
nullable: true is removed and "null" is added to the allowed types, so type: string becomes type: ["string", "null"]. If the schema has an enum, null is added to the list too. When there is no type to extend, for example a $ref with nullable next to it, the schema is wrapped as anyOf: [the original, { type: null }].
What else gets changed on the way?
$ref paths move from #/components/schemas/ or #/definitions/ to #/$defs/, example becomes a one-item examples array, and the boolean exclusiveMinimum / exclusiveMaximum from OpenAPI 3.0 turn into the numeric form JSON Schema expects (minimum: 0 plus exclusiveMinimum: true becomes exclusiveMinimum: 0). xml, discriminator and externalDocs are dropped. Numbers such as default, enum and maximum values are copied exactly as written, so 8901240544102066246 or 14.50 stay as they are.
Can I extract a single schema or must I take all of them?
Pick a schema by name from the dropdown above the output, or keep "All schemas (bundled)" for one document with everything under $defs. A single schema still carries the other schemas in its $defs block, so any $ref inside it keeps resolving.
Which validators accept the output?
We check the output with AJV. Python jsonschema and gojsonschema read Draft 7 as well, and json-schema-to-typescript can turn the file into TypeScript types. Vendor extensions such as x-something are left in place, so run AJV with strict mode off or remove them first.
Does it support Swagger 2.0 as well as OpenAPI 3?
Yes. For Swagger 2.0 the schemas come from the definitions object, and type: file (which JSON Schema has no word for) becomes a string with format binary. If you want to move the whole spec to OpenAPI 3.0, the Swagger to OpenAPI converter does that.
Is my spec uploaded anywhere?
No. The conversion runs in your browser and the spec is not sent to a server. The page is free and needs no sign-up.
Related: Swagger to OpenAPI · JSON Schema to OpenAPI (the other direction) · OpenAPI Validator
Related Tools
OpenAPI Validator
Validate OpenAPI 3.0 and Swagger 2.0 specifications online. Check required fields, paths, operations, schemas, and security schemes with instant error reporting.
JSON to OpenAPI
Generate OpenAPI/Swagger specifications from JSON examples. Infer data types and create complete API schemas automatically.
OpenAPI Fixer
Fix broken OpenAPI and Swagger specifications automatically, repair malformed paths, schemas, $ref references, and YAML syntax errors
OpenAPI to Rust
Generate type-safe Rust API client code from OpenAPI/Swagger specifications with serde annotations.
OpenAPI to Go
Generate type-safe Go structs with JSON tags from OpenAPI 3.0 and Swagger 2.0 specifications.
OpenAPI to TypeScript
Convert OpenAPI 3.0 and Swagger 2.0 specifications to TypeScript interfaces and types. Auto-generate type-safe TypeScript from any OpenAPI schema.