JSON to TypeScript, Zod and Go
Generate TypeScript interfaces, Zod schemas, JSON Schema (2020-12) or Go structs from sample JSON — or TypeScript from a GraphQL schema and operation.
About this tool
Generate TypeScript types, Zod schemas, JSON Schema or Go structs from a JSON sample, or TypeScript types from a GraphQL schema (SDL or introspection JSON) with an optional operation for result and variable types.
Types are inferred from the sample you paste, so a field missing from the sample is missing from the output, and a value that is sometimes null becomes a nullable or optional field only if the sample shows it. Treat the output as a starting point.
How to use it
- Paste a JSON sample, such as an API response.
- Choose TypeScript, Zod, JSON Schema or Go, and name the root type.
- Generate and copy the code, then review it: fields missing from the sample are missing from the types.
Example
Input:
{"id":1,"name":"Ada","tags":["math"]}TypeScript, root type User:
export interface User {
id: number;
name: string;
tags: string[];
}