JSON Schema to OpenAPI Converter - Convert JSON Schema Definitions to OpenAPI 3.0 Components
Free online tool to convert JSON Schema definitions to OpenAPI 3.0 components/schemas. Automatically rewrites $defs and $ref paths to OpenAPI format, removes JSON Schema-specific keywords, and wraps everything in a valid OpenAPI 3.0 spec. Use alongside our OpenAPI Validator to verify the result.
How to Convert JSON Schema to OpenAPI 3.0 - Step by Step Guide
Wrap JSON Schema definitions into a valid OpenAPI 3.0 components/schemas structure
Paste Your JSON Schema
Paste your JSON Schema (Draft-04 through Draft-2020-12). The converter extracts schemas from $defs or definitions and places each one in components/schemas:
.json schema file directly from disk$defsExample: JSON Schema Input with $defs
A JSON Schema with named definitions and $ref references:
{ "$schema": "https://json-schema.org/draft-07/schema", "title": "Product", "$defs": { "Product": { "type": "object", "required": ["id", "name"], "properties": { "id": { "type": "integer" } "name": { "$ref": "#/$defs/Name" } } } } }
Auto-Generated OpenAPI 3.0 YAML
The converter wraps your schemas in a complete OpenAPI 3.0 structure and rewrites all $ref paths from JSON Schema format to OpenAPI format:
#/$defs/Foo and #/definitions/Foo become #/components/schemas/Foo$schema and $id are stripped — they are not valid in OpenAPI 3.0openapi, info, paths, and components so the result is a valid OpenAPI documentExample: Generated OpenAPI 3.0 Output
Schemas placed under components/schemas with rewritten $refs:
openapi: 3.0.3 info: title: Product API version: 1.0.0 components: schemas: Product: type: object required: [id, name] properties: name: $ref: '#/components/schemas/Name'
Download, Validate, and Use
The output is a complete OpenAPI 3.0 YAML spec ready to use with any OpenAPI tooling:
paths, security, and servers to the downloaded YAML to complete your specWhat is JSON Schema to OpenAPI Conversion?
JSON Schema and OpenAPI 3.0 use very similar schema languages — OpenAPI's schema object is a subset of JSON Schema Draft-07. This means most JSON Schema definitions can be used directly inside an OpenAPI spec with only minor adjustments to reference paths and metadata fields.
The key differences this converter handles: JSON Schema stores named schemas under $defs (Draft-2019-09+) or definitions (Draft-07), while OpenAPI stores them under components/schemas. Accordingly, $ref paths like #/$defs/Foo must be rewritten to #/components/schemas/Foo. The $schema and $id meta-schema keywords are also removed as they are not part of the OpenAPI schema object.
After conversion, you'll typically add paths, servers, and security sections to complete the spec. The reverse operation — extracting JSON Schema from OpenAPI — is available via our OpenAPI to JSON Schema converter.
Frequently Asked Questions
What JSON Schema drafts are supported?
The converter works with Draft-04, Draft-06, Draft-07, Draft-2019-09, and Draft-2020-12. It handles both definitions (older drafts) and $defs (newer drafts) as sources for named schemas.
Are all JSON Schema keywords compatible with OpenAPI 3.0?
Most core keywords are compatible — type, properties, required, enum, allOf, oneOf, anyOf, items, and format all work directly. JSON Schema-only keywords like const, contentMediaType, and $anchor are not part of OpenAPI and may need manual cleanup after conversion.
What happens to the root schema if it has no $defs?
If the JSON Schema has no $defs or definitions, the root schema itself is placed in components/schemas using the title field as the schema name (or "Schema" if no title is set).
Can I reverse this — extract JSON Schema from an OpenAPI spec?
Yes. Use our OpenAPI to JSON Schema converter to extract component schemas from an OpenAPI 3.0 or Swagger 2.0 spec as standalone JSON Schema files.
Will the output be a complete, valid OpenAPI spec?
The output includes all required OpenAPI fields (openapi, info, paths) so it passes structural validation. However, the paths object is empty — you will need to add your API endpoints manually. Run the output through our OpenAPI Validator to check it.
Is this converter free?
Yes, completely free with no limits on schema size. No registration required. All conversion runs entirely in your browser — your schema 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.