JSON Schema to TypeScript
Convert a JSON Schema (draft-07) into TypeScript interfaces and type aliases — properties, required, enums, unions, $refs and nested objects included. Runs entirely in your browser.
JSON Schema
How it works
- Supports
type,properties+required,additionalProperties,items(single schema or tuple array),enum→ union literals, andanyOf/oneOf→ unions. - Local
$refs into#/$defsor#/definitionsare resolved — referenced definitions become named interfaces/aliases too. "null"in thetypelist orx-nullable: trueproducesT | null.- Strict mode keeps
requiredproperties as non-optional (: T); otherwise every property becomes?: T. formatandpatternare ignored — they don’t affect the emitted type.
About JSON Schema to TypeScript
API contracts, config files and data fixtures are increasingly described with JSON Schema — but consuming that schema in TypeScript usually means either hand-writing the interfaces or pulling in a heavy build-time plugin. This tool does the translation in one pass: object schemas become interfaces, everything else collapses to primitive or union types, and local $defs/definitions are emitted as their own named declarations so the output stays readable.
The generated code is plain TypeScript — no dependencies, no generics machinery — so you can paste it into a .d.ts file or an existing source file and start using it immediately. The strict-mode toggle matches the two common conventions (all-optional by default vs. required-only-non-optional), and the prefix control avoids name collisions when you generate types for several schemas into the same file.