OpenAPI to JSON Schema Converter - Extract JSON Schema Draft 7 from OpenAPI / Swagger Specs
Free online tool to convert OpenAPI 3.0 and Swagger 2.0 component schemas to JSON Schema Draft 7. Handles nullable, $ref rewriting, and OpenAPI extensions. Works with AJV, Zod, jsonschema and any JSON Schema validator. 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.0 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:
nullable: true becomes {"oneOf": [schema, {"type": "null"}]} — standard JSON Schema syntax#/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 converted to JSON Schema Draft 7 with nullable as oneOf and updated $ref paths:
{ "$schema": "https://json-schema.org/draft-07/schema", "type": "object", "required": ["id", "email"], "properties": { "active": { "oneOf": [ { "type": "boolean" }, { "type": "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. In JSON Schema Draft 7, this is expressed as {"oneOf": [schema, {"type": "null"}]}. 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?
The output targets JSON Schema Draft 7, which is the most widely supported version and is what AJV, react-jsonschema-form, and most other tools default to. The $schema keyword is set to the Draft 7 URI.
How is OpenAPI nullable handled?
OpenAPI's nullable: true extension is converted to a {"oneOf": [originalSchema, {"type": "null"}]} construct — the correct JSON Schema Draft 7 way to allow null. Note that JSON Schema 2019-09+ uses type: ["string", "null"] instead, but Draft 7 requires the oneOf approach.
Can I extract a single schema or must I take all of them?
Use the dropdown in the output panel to select a specific schema by name, or choose "All schemas (bundled)" to get a single document with all schemas in a $defs block. The bundled document is needed when schemas reference each other via $ref.
Does it support allOf, oneOf, anyOf?
Yes. allOf, oneOf, and anyOf are all preserved in the output and are fully valid JSON Schema. Nested schemas within these keywords are recursively converted. Read more about OpenAPI composition keywords.
Which validators accept this JSON Schema output?
AJV (JavaScript), jsonschema (Python), and gojsonschema (Go) all work with Draft 7. For TypeScript, use json-schema-to-typescript to generate types from the output.
Does it support Swagger 2.0 as well as OpenAPI 3.0?
Yes. For Swagger 2.0 specs, schemas are read from the definitions object and $ref paths are rewritten from #/definitions/ to #/$defs/. You can also use our Swagger to OpenAPI converter first if you prefer to work with a 3.0 spec.
Is this OpenAPI to JSON Schema converter free?
Yes, completely free with no limits on spec size or number of schemas. No registration required. All conversion runs in your browser — your spec never leaves your device.
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 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.
OpenAPI to Markdown
Convert OpenAPI 3.0 and Swagger 2.0 specifications to readable Markdown API documentation. Generate endpoint tables, parameter docs, and schema references.