Skip to content
100% local

TypeScript type to JSON Schema

Convert a TypeScript interface or type alias into JSON Schema.

Input
Output

TypeScript type to JSON Schema

Paste a TypeScript interface or type alias and this tool generates the equivalent JSON Schema, ready to validate API payloads, configuration files or any other JSON data that should match your type definitions. It's built for developers who already describe their data shapes in TypeScript and want a schema without hand-writing one from scratch or wiring up a build step.

Choose between JSON Schema draft-07 and the newer 2020-12 dialect, since validators and tools still differ on which one they expect. String-literal unions like 'active' | 'inactive' can render either as an enum or as anyOf of const values, and you can require objects to reject unknown properties, turn doc comments into description fields, or extract named interfaces into a $defs (or definitions) block referenced by $ref instead of inlining them everywhere they're used.

Arrays, tuples, Record and Map types, and unions that include null are all handled the way TypeScript actually uses them — a nullable field becomes a type array or an anyOf branch rather than being silently dropped. Constructs with no JSON Schema equivalent, such as methods, function types or unresolved generic parameters, are converted as permissively as possible and listed as warnings under the result so nothing fails silently.

Everything runs locally in your browser; your type definitions and the generated schema are never uploaded anywhere. Copy the result, download it as a .txt file, or send it straight into another tool's input to keep working on it.

FAQ

Which parts of TypeScript can it convert?
Interfaces, type aliases, nested object literals, arrays, tuples, Record/Map/Set, Date, Partial/Required/Pick/Omit, and unions including string-literal unions and null. Constructs with no JSON Schema equivalent, like methods and function types, are skipped and listed as warnings.
What's the difference between draft-07 and 2020-12?
Both are JSON Schema dialects. 2020-12 is the current one and uses $defs and prefixItems for tuples, while draft-07 uses definitions and an items array. Pick whichever your validator expects.
What happens to properties marked with '?'?
They're left out of the schema's required array, so the generated schema matches TypeScript's own idea of which fields are optional.
Why do some fields end up as an empty schema {}?
That happens for constructs JSON Schema can't express, such as a generic type parameter or a type the tool couldn't resolve. A warning is added below the result explaining exactly which field and why.
Is my TypeScript code uploaded anywhere?
No. Conversion runs entirely in your browser — your type definitions and the generated schema never leave your device.