New
TypeScript to Zod Converter
Runs in browserConvert TypeScript interfaces and type definitions to Zod validation schemas instantly. Supports Zod v3 and v4, optional fields, union types, enums, arrays, Records, and nested objects.
TypeScript to Zod Converter tool
Zod version:
Export:
import { z } from "zod";
export const userSchema = z.object({
id: z.number(),
name: z.string(),
email: z.string(),
age: z.number().optional(),
role: z.enum(["admin", "user", "viewer"]),
tags: z.array(z.string()),
address: z.object({
city: z.string(),
country: z.string(),
zip: z.string().optional(),
}),
createdAt: z.date(),
metadata: z.record(z.string(), z.unknown()),
deletedAt: z.date().nullable(),
});How to use
Paste TypeScript
Paste interfaces, type aliases, or enums in the left panel.
Choose Zod version
Select v3 or v4 and whether to export const or use local const.
Copy or download
Copy the generated schema or download it as a .ts file.
Examples
User interface
Convert a User interface to a Zod schema.
Inputinterface User { id: number; name: string; email: string; }Outputexport const userSchema = z.object({ id: z.number(), name: z.string(), email: z.string() });
Frequently asked questions
- Does it handle nested objects?
- Yes. Inline object types like address: { city: string; zip?: string } are converted to nested z.object() schemas.
- What types are not supported?
- Generics (e.g. Response<T>), conditional types, and mapped types fall back to z.unknown() with a comment.
Related tools
You might find these useful too.