Code Beautifier

JSON Schema to TypeScript

Convert a JSON Schema into TypeScript interfaces and types, including $defs references, recursive schemas, enums, and nullable unions.

Draft saved locally.

Local workspace

Named projects in IndexedDB · Local only — never synced to our servers. Worksp

Open manager

Batch workspace

Format multiple files locally in one run.

Declaration:
json
TypeScripttypescript

Options

OptionDescription
DeclarationObject schemas become interfaces or type aliases. Unions and other non-object schemas are always type aliases.
Root nameName of the top-level type. Leave empty to use the schema's title.

FAQ

Are $ref references to other files resolved?

Local references such as #/$defs/Address or #/definitions/Node become named types. External files and URLs are never fetched; those references are typed as unknown, and a warning at the top of the output lists them.

How are recursive schemas handled?

Every referenced definition is declared once and then referred to by name, so a Node schema whose children are Nodes becomes interface Node { children?: Node[] }.

How do required and optional properties map to TypeScript?

Properties listed in required are written without a question mark, and every other property is optional with ?.

What happens to anyOf, oneOf, and allOf?

anyOf and oneOf become unions and allOf becomes an intersection. TypeScript can't express oneOf's "exactly one" rule, so validate that at runtime if it matters.

Are schema descriptions kept?

Yes. A description becomes a JSDoc comment above the property or type, so editors show it on hover.