New

TypeScript to Zod Converter

Runs in browser

Convert 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

  1. Paste TypeScript

    Paste interfaces, type aliases, or enums in the left panel.

  2. Choose Zod version

    Select v3 or v4 and whether to export const or use local const.

  3. 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.

    Input
    interface User { id: number; name: string; email: string; }
    Output
    export 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.

You might find these useful too.