>_devtools

JSON Schema to TypeScript

Convert a JSON Schema into TypeScript interfaces and types, with $defs, enums, unions, and tuples.

What this does

Generates TypeScript declarations from a JSON Schema. Object schemas with properties becomeinterfaces, everything else becomes a type alias, and each entry in$defs (or definitions) becomes its own named export that other types refer to.

{
  "title": "User",
  "type": "object",
  "required": ["id"],
  "properties": {
    "id": { "type": "integer" },
    "role": { "enum": ["admin", "member"] },
    "address": { "$ref": "#/$defs/address" }
  },
  "$defs": {
    "address": { "type": "object", "properties": { "city": { "type": "string" } } }
  }
}

With the root name Root this produces:

export interface Root {
  id: number;
  role?: "admin" | "member";
  address?: Address;
}

export interface Address {
  city?: string;
}

How keywords map to types

  • string, number/integer (both number), boolean, and null map directly; a type list becomes a union.
  • Properties not listed in required become optional (name?: type). Property names that are not valid identifiers are quoted.
  • enum and const become unions of literal types.
  • items becomes T[]; prefixItems (or array-form items) becomes a tuple, with a rest element when more items are allowed.
  • anyOf and oneOf become unions; allOf becomes an intersection.
  • additionalProperties with a schema becomes an index signature; with false and no properties, Record<string, never>.
  • description becomes a JSDoc comment.

What is not expressed

TypeScript types cannot represent value constraints such as minLength, pattern,minimum, or format, so those are dropped; use the Zod converter if you need runtime checks. Local references (#, #/$defs/...) are resolved, including recursive ones. A reference to another file or URL is never fetched and becomes unknown, with a warning under the output. Input is limited to 1 MB.

Privacy

The conversion runs in your browser. Your schema is never uploaded or stored.