Zero Signup ToolsFree browser tools

Developer Tools

TypeScript to Zod Converter

Convert TypeScript interfaces, types, and enums to Zod schemas in your browser. Supports unions, literals, arrays, tuples, Record, Partial, and z.infer types.

0 chars

Output options

Live preview updates with every change. Parsing and code generation run in your browser; the TypeScript pasted here is not uploaded.

Indent

Each declaration is exported as <Name><suffix>. Defaults to "Schema" so User becomes UserSchema.

How to use

  1. Paste a TypeScript interface, type alias, or enum into the input on the left, or click Load sample to start with a worked User example.
  2. Read the generated Zod schema on the right. The result chips show how many schemas were generated and whether any pieces had to be flagged as unsupported.
  3. Adjust the schema name suffix (defaults to Schema, so User becomes UserSchema), pick 2 or 4 space indent, and toggle Export schemas if you want each constant prepended with export.
  4. Toggle Emit z.infer types to add type XType = z.infer<typeof XSchema> after each schema, so the runtime-validated shape is reusable as a static type.
  5. Click Copy schema to put the full file on your clipboard, then paste it into your project alongside import { z } from "zod".

About this tool

TypeScript to Zod Converter reads a subset of TypeScript declarations and emits runtime-validated Zod v3 schemas, entirely in your browser. The parser understands interface and type aliases, enum declarations (both string and numeric), optional and readonly properties, primitives (string, number, boolean, bigint, Date, null, undefined, unknown, any, never, void, symbol), literal types, arrays and ReadonlyArray, tuples, object literal types with index signatures, unions, intersections, generic wrappers (Partial, Required, Readonly, NonNullable, Record), and references to other declarations in the same input. Smart collapses keep the output idiomatic: a union of string literals turns into z.enum([...]), T | null becomes .nullable(), T | undefined becomes .optional(), an interface that extends another inherits the parent properties, an index signature ([k: string]: V) intersects a z.record with the explicit object, a TypeScript enum becomes a runtime const object plus a z.nativeEnum schema, and forward references between declarations are wrapped in z.lazy so circular shapes round-trip cleanly. Each emitted constant is followed by an optional type XType = z.infer<typeof XSchema> so the runtime-validated shape stays usable as a static type. Output options let you toggle the export modifier, choose 2 or 4 space indent, change the schema name suffix, and turn the inferred type aliases on or off. Anything the parser does not understand (mapped types, conditional types, template literal types, generics on the user's own declarations) is replaced with z.unknown() and an inline comment so you can see exactly where to hand-edit. Useful for tRPC inputs and outputs, Next.js Server Action validation, React Hook Form resolvers, Express and Fastify middleware, OpenAPI client validation, and any project where the type system needs a runtime companion. Parsing and code generation run locally on your device, so the TypeScript pasted here never leaves your browser.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools