Skip to content
Schema helper

JSON to OpenAPI schema

Create an OpenAPI 3.1.0 schema from a JSON sample. The output is a minimal document: info has the title Generated API and version 1.0.0, and the schema inferred from your sample goes in components.schemas.Root. When array elements have different shapes they are merged into one schema, and only keys present in every element go into required. A date-time string such as 2024-01-02T03:04:05Z gets format: date-time, and null becomes type: "null", the OpenAPI 3.1 way. You can paste it into Swagger Editor to inspect it, but paths is empty so add your endpoints by hand, along with constraints such as description, example and enum. Everything runs in your browser and your JSON is not sent anywhere.

Guide

How to use & features

  • Paste JSON into the input and hit “Convert to OpenAPI.”
  • Objects expand into JSON Schema with properties plus a required array.
  • Arrays infer the element type; if multiple types appear, the tool outputs oneOf.
  • Use copy or clear to reuse the schema or start fresh.
Samples

Sample input & output

Infer schema from a profile object

Input
{"name":"Jane","email":"jane@example.com","verified":true}
Output
{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "email": {"type": "string", "format": "email"},
    "verified": {"type": "boolean"}
  },
  "required": ["name", "email", "verified"]
}
FAQ

FAQ

  • What OpenAPI document does it output?

    A minimal OpenAPI 3.1.0 document. `info` has the title `Generated API` and version `1.0.0`, `paths` is empty, and the schema inferred from your sample goes in `components.schemas.Root`.
  • Can I use it in Swagger Editor?

    Yes. Paste the output and you can inspect the `Root` schema. `paths` is empty, so add your endpoints by hand.
  • What happens when array elements have different shapes?

    They are merged into one schema. Only keys present in every element go into `required`; keys in only some do not. `oneOf` appears only when the kinds of value differ.
  • How are date-time strings handled?

    An ISO 8601 date-time such as `2024-01-02T03:04:05Z` becomes `type: string` with `format: date-time`. A date alone, such as `2024-01-02`, is a plain `string`.
  • What about `null` and empty arrays?

    `null` becomes `type: "null"` (the 3.1 way). An empty array becomes `items: {}` because the element shape is unknown.
  • Is my JSON sent anywhere?

    No. Conversion happens entirely in your browser.
Use cases

Common use cases

  • Drafting an API design

    Build a schema skeleton from a sample response, then add descriptions and constraints to turn it into a design document.
  • Writing the schema of an existing API from its response

    Paste a real response to quickly write up the schema of an API that has no documentation.
  • Feeding a mock server or code generator

    Use the output as a starting point for a mock server or client-generation tool.
  • Sharing the shape of data in a review

    Show key types and whether keys are required as a schema, which a JSON sample alone communicates poorly.
Notes

Notes & limitations

  • `paths` is empty

    Endpoints (path, method, request and response) are not included. What you get is the schema under `components.schemas`.
  • It infers from a single sample

    `description`, `example`, `enum` and length or range constraints are not included. Add them by hand to match your spec.
  • It uses OpenAPI 3.1 conventions

    `null` becomes a `oneOf` with `type: "null"`; `nullable: true` is not used. Tools that assume 3.0 or earlier need it rewritten.
  • Whether a key is required depends on the sample

    Keys present in every array element go into `required`. A key that merely happens to be in every sample element becomes required too, so check against the real specification.
About

About this tool

JSON to OpenAPI Schema Generator

Instantly infer and generate OpenAPI (Swagger) 3.x components.schemas YAML/JSON definitions by simply pasting an exogenous API response or a design-phase dummy JSON object.
During REST API development or technical documentation authoring, manually mapping out massive JSON properties and dictating types is a tedious, error-prone task. This structural inference tool automates the heavy lifting of reverse-engineering your API schema, accelerating your documentation process.

Articles for this tool

Recent Articles