Tool description

Convert TypeScript type to Zod schema automatically. Transform any interface to Zod validation schema or generate Zod from interface definitions without manual rewriting. Perfect for converting TS type to Zod in seconds.

Features

  • Automatically converts interface to Zod schema format with matching validation rules.
  • Transforms TypeScript type to Zod schema including primitives, nested objects, arrays, tuples, literal unions, and optional properties.
  • Detects multiple interfaces and type aliases in a single snippet and generates corresponding Zod constants.

Conversion Details

  • Maps common primitives to z.string(), z.number(), z.boolean(), z.null(), z.undefined(), and z.unknown().
  • Converts literal unions to z.enum([...]) when all members are strings, otherwise falls back to z.union([...]).
  • Generates z.object({...}) for inline object literals and chains .catchall() for index signatures.
  • Produces actionable warnings whenever the converter must fall back to z.any() or skip an interface extension.