JSON Schema → TypeScript
Generate TypeScript interfaces from a JSON Schema — $ref resolution, required/optional, enums, and union types. 100% local.
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.
{
"$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" } }
}
}/** 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 keyword | TypeScript output | Notes |
|---|---|---|
| type: "string" | string | |
| type: "number" / "integer" | number | Both map to number |
| type: "boolean" | boolean | |
| type: "null" | null | |
| type: "array" + items | T[] | Element type from items |
| type: "object" + properties | interface { ... } | Named interface, hoisted |
| required: ["x"] | x: T (no ?) | Required = non-optional |
| (key absent from required) | x?: T | Optional field |
| enum: ["a","b"] | "a" | "b" | String union of literals |
| enum: [1, "x", true] | 1 | "x" | true | Mixed literal union |
| anyOf / oneOf | A | B | C | Union type |
| allOf (objects) | Merged interface | Properties are combined |
| allOf (mixed) | A & B | Intersection type |
| $ref: "#/$defs/Foo" | Foo | Resolved to named interface |
| description | /** ... */ | JSDoc comment above field/type |
| nullable: true | T | null | OpenAPI 3.0 extension |
| additionalProperties: true | [key: string]: unknown | Index signature added |
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.
https://example.com/schemas/user.json) are not supported. Only document-local references starting with #/ are resolved.Try It
Frequently Asked Questions
Your files stay on your computer. Dad promised.