JSON Schema to TypeScript

Paste a JSON Schema (draft-07 or 2020-12) on the left and get TypeScript interfaces on the right. Same algorithm as the /api/convert HTTP API and the @solvohq/json-to-ts npm CLI — pick the shape that fits your workflow.

JSON input valid
TypeScript output

      
    

About this conversion

JSON Schema is the lingua franca of API contracts: OpenAPI components.schemas, AsyncAPI message payloads, ajv validators, configuration documents, MCP tool inputs — they're all JSON Schema variants under the hood. Converting a schema into TypeScript types is the bridge between the contract and the consumer code that has to satisfy it. This converter handles the keyword set you actually paste day-to-day: type (single or array union), properties, items, required, enum, and $ref to local #/definitions, #/$defs, or OpenAPI components.schemas.

Paste your schema on the left; the right pane updates as you type with one TypeScript interface per object schema and one type alias per primitive / union / array root. required entries become non-optional fields; everything else becomes optional. enum values become a string-literal union (or generic union for mixed types). A nullable string written as type: ['string', 'null'] becomes string | null. Nested objects get their own interface with a name lifted from the property key — the same naming algorithm used by the JSON-sample converter, so output is consistent across the two input modes.

What's deliberately out of scope: composition keywords (allOf / oneOf / anyOf) return 501 — they're best handled by flattening in the source schema before paste, since one composed type can have many valid TypeScript shapings. Remote $ref (https://...) returns 400 — the converter is local-resolution-only by design (no surprise network calls from your browser tab). String format (date, email, uuid) is captured as plain string. The same conversion is available as an HTTP API at /api/convert — pass {"schema": "<stringified-schema>", "mode": "ts"} instead of {"json": ...}.

Same shape, other validators

Other JSON shapes