Skip to content
Categories
JSON Schema to TypeScript / Zod
Generate a TypeScript interface or Zod schema from a JSON Schema.
Overview
- Enter a JSON Schema and generate the corresponding TypeScript interface definition or Zod validation schema code.
- Supports the object, string, number, integer, boolean, array, and enum types, as well as the distinction between required and optional properties via `required`.
- Unlike the existing json-to-typescript tool (which infers types from a JSON value), this generates precise types/schemas from a JSON Schema definition that already carries type information.
Usage
- Paste the JSON Schema into the input field.
- Specify the target (TypeScript or Zod) and the type/variable name.
- Click the "Convert" button to see the generated code.
Example
Input
{"type":"object","properties":{"id":{"type":"string"}},"required":["id"]}Output
export interface Root {
id: string;
}Use Cases
- Generating TypeScript types for frontend use from a schema definition in API documentation (such as OpenAPI)
- Replacing JSON Schema-based validation with runtime validation using Zod
- Reviewing the structure represented by a JSON Schema in a more readable code form
FAQ
Are schema references with $ref supported?
No. Currently only a single schema definition without $ref is supported.
Are oneOf, anyOf, and allOf supported?
No. Currently only type, properties, required, items, and enum are supported.
Can the generated code be used as-is?
The TypeScript interface can be used as-is. For the Zod code, you'll need to separately add `import { z } from "zod";`.
Notes
- The type/variable name must start with a letter or underscore and contain only letters, digits, or underscores.
- The conversion happens entirely in your browser.
Related Tools
Generate TypeScript type definitions from JSON.
Validate whether JSON is correctly formatted.
Convert JSON into YAML format.