← All Tools

TypeScript → Zod Schema

Drop in TypeScript interface or type declarations and get back equivalent Zod schemas — the runtime mirror of your compile-time types. Useful when you want one source of truth that validates HTTP payloads, form input, or env vars without writing parsers by hand.

What's supported

Primitivesstring, number, boolean, bigint, null, undefined, any, unknown, never, void, Date.

Composites — arrays (T[], Array<T>, ReadonlyArray<T>), tuples ([A, B, C]), records (Record<K, V>), nested objects, and inline object literals.

Type operators — unions (A | B), intersections (A & B), literal types ("foo", 42, true, null), optional properties (name?: T), nullable (T | null).

Declarationsinterface X { … } (including extends) and type X = …. Generic parameters on type aliases are inlined into the schema as z.any() placeholders — Zod doesn't have first-class generics.

Not supported — conditional types, mapped types, template literal types, typeof queries, keyof, function signatures. They emit z.unknown() with a comment.