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(bothnumber),boolean, andnullmap directly; a type list becomes a union.- Properties not listed in
requiredbecome optional (name?: type). Property names that are not valid identifiers are quoted. enumandconstbecome unions of literal types.itemsbecomesT[];prefixItems(or array-formitems) becomes a tuple, with a rest element when more items are allowed.anyOfandoneOfbecome unions;allOfbecomes an intersection.additionalPropertieswith a schema becomes an index signature; withfalseand no properties,Record<string, never>.descriptionbecomes 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.