Dad’s Data formats tools

JSON Schema → TypeScript

Generate TypeScript interfaces from a JSON Schema — $ref resolution, required/optional, enums, and union types. 100% local.

JSON Schema Input
Root type name(used when schema has no title)
TypeScript Output
Paste a JSON Schema to generate TypeScript interfaces.

How It Works

This tool parses a JSON Schema document and generates TypeScript interface and type declarations. Unlike the JSON → TypeScript tool which infers types from runtime values, this tool reads the explicit contract defined in your schema — including required fields, optional fields, enums, unions, and cross-references via $ref.

Input
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "User",
  "description": "A user account",
  "type": "object",
  "required": ["id", "name", "role"],
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "email": { "type": "string" },
    "role": { "type": "string", "enum": ["admin", "editor", "viewer"] },
    "address": {
      "type": "object",
      "required": ["city", "country"],
      "properties": {
        "city": { "type": "string" },
        "country": { "type": "string" }
      }
    },
    "tags": { "type": "array", "items": { "type": "string" } }
  }
}
Output
/** A user account */
export interface User {
  id: number;
  name: string;
  email?: string;
  role: "admin" | "editor" | "viewer";
  address?: Address;
  tags?: string[];
}

export interface Address {
  city: string;
  country: string;
}

Keyword Support

JSON Schema keywordTypeScript outputNotes
type: "string"string
type: "number" / "integer"numberBoth map to number
type: "boolean"boolean
type: "null"null
type: "array" + itemsT[]Element type from items
type: "object" + propertiesinterface { ... }Named interface, hoisted
required: ["x"]x: T (no ?)Required = non-optional
(key absent from required)x?: TOptional field
enum: ["a","b"]"a" | "b"String union of literals
enum: [1, "x", true]1 | "x" | trueMixed literal union
anyOf / oneOfA | B | CUnion type
allOf (objects)Merged interfaceProperties are combined
allOf (mixed)A & BIntersection type
$ref: "#/$defs/Foo"FooResolved to named interface
description/** ... */JSDoc comment above field/type
nullable: trueT | nullOpenAPI 3.0 extension
additionalProperties: true[key: string]: unknownIndex signature added
Tip: The root type name comes from the schema's title field when present. If your schema has no title, the “Root type name” input above the editor is used as the fallback.

$ref and $defs Resolution

Local references (#/$defs/TypeName and #/definitions/TypeName) are fully resolved. Each referenced definition becomes its own exported interface or type. Circular references within the same document are handled — the first reference reserves the name, and subsequent uses receive the already-allocated name.

Warning: Remote $ref URIs (e.g. https://example.com/schemas/user.json) are not supported. Only document-local references starting with #/ are resolved.

Try It

Interactive — edit the input to see the output update
Try it
Result

Frequently Asked Questions

Your files stay on your computer. Dad promised.

Data formats tools

Search the Data formats tools