JSON Schema to TypeScript

Turn a JSON Schema into TypeScript declarations you can paste into your project.

Use the tool

Why this tool exists

Properties become interface members, optional unless listed in required; enum and const become literal unions; type arrays such as ["string","null"] become unions; oneOf and anyOf become unions and allOf becomes an intersection; $ref to #/$defs or #/definitions becomes a named type; additionalProperties maps to index signatures; descriptions become JSDoc comments. The output was compiled with tsc against valid and invalid sample values.

Schema features that TypeScript cannot express (patterns, min/max, formats) are not enforced by the types. Remote $ref files are not fetched.

No data is sent anywhere: the work happens in your browser, so you can use it offline once the page has loaded.

How to use it

  1. Paste the JSON Schema.
  2. Set the root type name and style.
  3. Copy the generated declarations.
  4. Validate data at runtime with the JSON Schema validator.

Frequently asked questions

Does it support $ref to other files?

Only references inside the same document (#/$defs/... or #/definitions/...).

How are integers typed?

As number, because TypeScript has no integer type.

What about additionalProperties: false?

It produces an object type without an index signature.

Is my data sent anywhere?

No. Everything is processed in your browser, and the page makes no network requests with your input.