04 Convert

JSON Schema to TypeScript

Generate TypeScript interfaces and types from a JSON Schema. Definitions become named types, so the output stays readable and recursive schemas just work.

Code editor. Press Escape, then Tab, to move focus out of the editor.

      How to convert a schema to TypeScript

      1. Paste a JSON Schema on the left, open a file, or load one from your stash.
      2. Pick the declaration style and options. The TypeScript updates as you type.
      3. Copy the code or download it as a .ts file.

      Objects become interfaces with required and optional (?) properties. enum and const become literal unions, oneOf/anyOf become unions and allOf becomes an intersection. prefixItems (or array-form items) become tuples, additionalProperties schemas become index signatures or Record, and "type": ["string", "null"] becomes string | null. Titles and descriptions turn into JSDoc comments.

      Options

      interface / type
      Plain object schemas become interface declarations or type aliases. Unions and other shapes are always type aliases.
      export and readonly
      Prefix every declaration with export, and mark properties and arrays readonly.
      Index signatures
      Adds [key: string]: unknown to objects that allow extra properties.

      FAQ

      How are $ref and $defs handled?

      Every entry in $defs or definitions becomes its own named type, and each $ref uses that name instead of copying the schema. That keeps the output short and makes recursive schemas work.

      Why are open objects not given an index signature by default?

      JSON Schema allows extra properties unless additionalProperties is false, but adding [key: string]: unknown everywhere makes types harder to use. Turn on the index signature option if you want that strictness.

      Which keywords cannot be expressed in TypeScript?

      Value constraints such as minLength, pattern, minimum and format have no type-level equivalent, and not, if/then/else and dependentSchemas are ignored. Use the Zod converter if you need runtime checks.