Home → JSON to OpenAPI Schema Generator
Generate OpenAPI 3.0 schema definitions from a sample JSON response.
Generate OpenAPI 3.0 schema definitions from a sample JSON response. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.
OpenAPI (formerly Swagger) is the industry standard for describing REST APIs in a machine-readable format.
OpenAPI uses JSON Schema-like syntax to describe request bodies, response bodies, and query parameters. Schema objects define field names, types, formats, required status, and constraints like minimum, maximum, and pattern.
The tool generates schemas for both OpenAPI 3.0 and 3.1. Version 3.1 is fully JSON Schema compatible (draft 2020-12), while 3.0 uses a superset with some differences. Choose the version your toolchain supports.
The tool infers a complete OpenAPI schema from your JSON example, handling type detection and structure automatically.
Generate the requestBody schema for a POST or PUT endpoint from a sample request body. The output is ready to paste into your OpenAPI spec under the requestBody.content.application/json.schema path.
Generate a 200 OK response schema from a sample API response. Paste the output under responses.200.content.application/json.schema in your spec, or add it to components.schemas for reuse.
OpenAPI (formerly Swagger) is the industry standard for documenting REST APIs. Converting JSON response examples into OpenAPI schemas automates the documentation process.
// JSON API Response
{"id": 1, "name": "Alice", "email": "alice@example.com", "isPremium": true}
// OpenAPI 3.0 Schema
components:
schemas:
User:
type: object
required:
- id
- name
- email
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: Alice
email:
type: string
format: email
example: alice@example.com
isPremium:
type: boolean
example: true
| JSON Type | OpenAPI Schema | Notes |
|---|---|---|
| string | type: string | Add format: email, uri, date, etc. |
| integer | type: integer, format: int32/int64 | |
| float | type: number, format: float/double | |
| boolean | type: boolean | |
| null | nullable: true | OpenAPI 3.0; use type: [T, "null"] in 3.1 |
| array | type: array, items: {type: ...} | |
| object | type: object, properties: {...} | |
| date string | type: string, format: date-time | ISO 8601 |
Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff
The converter inspects each JSON value type and emits the corresponding OpenAPI 3.0 schema definition. The example below shows an input JSON object and the fully-generated schema component that you can paste directly into your OpenAPI specification.
// Input JSON example
{"id": 1, "name": "Alice", "email": "alice@example.com", "active": true, "score": 9.5, "tags": ["admin"]}
# Generated OpenAPI 3.0 schema
components:
schemas:
User:
type: object
properties:
id:
type: integer
name:
type: string
email:
type: string
active:
type: boolean
score:
type: number
tags:
type: array
items:
type: string
Once you have a generated schema component, you can reference it across your entire OpenAPI document using $ref. This avoids repeating the schema in every endpoint and keeps your spec DRY. The example below shows a complete minimal OpenAPI spec with a GET /users/{id} endpoint referencing the generated User schema.
openapi: 3.0.0
info:
title: My API
version: 1.0.0
paths:
/users/{id}:
get:
summary: Get user by ID
parameters:
- name: id
in: path
required: true
schema: { type: integer }
responses:
'200':
description: User found
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
# — paste generated schema here —