← All Tools

JSON Schema → TypeScript

Convert a JSON Schema document (draft 4 through 2020-12, plus OpenAPI 3.x schemas) into TypeScript interface and type declarations. Handles $ref, local definitions / $defs, oneOf / anyOf / allOf, tuples (prefixItems), enum, const, additionalProperties, and patternProperties. Everything runs locally; your schema never leaves the page.

schema chars 0 types emitted 0 $refs resolved 0
Examples:

Mapping cheat sheet

JSON SchemaTypeScript
"type": "string"string
"type": "number" / "integer"number
"type": "boolean"boolean
"type": "null"null
"type": ["string","null"]string | null
"enum": ["a","b"]"a" | "b"
"const": 4242
"type":"array","items":TT[]
"prefixItems":[A,B], "items":false[A, B]
"oneOf"/"anyOf":[A,B]A | B
"allOf":[A,B]A & B
"additionalProperties": T[k: string]: T
"$ref": "#/$defs/X"X
"required": [...]non-optional ?

Local refs of the form #/definitions/Foo, #/$defs/Foo, and OpenAPI-style #/components/schemas/Foo become named TypeScript types. External (http://) refs are emitted as unknown with a JSDoc note — fetching them would defeat the no-network promise.