JSON to TypeScript & Zod Generator

Paste any JSON below and instantly get matching TypeScript interfaces and Zod validation schemas. The generator merges the shape of every array item to detect optional fields, reuses a single type when a nested object shape repeats, and can turn repeated string values into literal union types (enums). Everything runs locally in your browser - your JSON is never uploaded to a server.

TypeScript style

Frequently asked questions

Is my JSON uploaded to a server?

No. The whole process - parsing the JSON, inferring the types, and generating the TypeScript and Zod code - runs 100% in your browser using plain JavaScript. Nothing is sent anywhere.

How does it decide if a field is optional?

When an array contains multiple objects, the generator compares every item's shape. If a key is missing from at least one item, it's marked optional (?) in TypeScript and with .optional() in Zod. If a key is present everywhere but sometimes null, it becomes a nullable union (T | null) instead of becoming optional.

What does the "Detect enums" option do?

When a string field repeats across array items with a small number of distinct values (2 to 8), this option turns it into a literal union type in TypeScript (e.g. 'paid' | 'pending') and a z.enum([...]) in Zod, instead of the generic string type. A value that only appears once is never turned into an enum.

Will the generated Zod schema work with Zod v3 and v4?

Yes. The output only uses the core, stable API (z.object, z.array, z.string, z.union, z.enum, .optional()), which is unchanged between Zod 3 and Zod 4, so you can paste it into either version.