Zod schema to TypeScript type
Convert a Zod schema definition into its matching TypeScript interface or type.
Zod schema to TypeScript type
Paste a Zod schema — a `z.object({...})` definition, optionally assigned to a `const` — and this tool outputs the TypeScript interface or type alias that `z.infer` would produce for it. It is useful whenever a schema is the source of truth and you want the matching static type without running a build step or a codegen CLI: for a quick sanity check while writing validation code, for documenting an API's shape from its Zod schema, or for porting a schema into a codebase that only needs the types.
The output options control the shape of the generated code. Choose between an `interface` and a `type` alias (a non-object schema, such as a bare union or string, always becomes a type alias, since TypeScript interfaces can only describe object shapes), and whether the declaration is `export`ed. Optional fields can render either as a question mark (`field?: string`) or as an explicit `string | undefined` union. A separate toggle keeps `z.enum`'s members as a literal union instead of collapsing them to `string`, and another turns `.describe("...")` calls into a docblock comment above each field.
Nested objects, arrays, tuples, unions, intersections, records, maps and sets all convert to their TypeScript equivalents, and common chained calls that only add runtime validation — `.min()`, `.email()`, `.refine()`, `.default()` and the like — are recognized and skipped rather than breaking the conversion. Recursive schemas built with `z.lazy(() => Schema)` are resolved back to a self-referencing type when the matching `const` is part of the same input; turn that option off to see `any` instead. Windows and Unix line endings are handled the same way, and the tally under the output reports how many declarations and fields were generated.
Everything runs in your browser. The schema you paste is never uploaded anywhere, so it is safe to use with an unreleased API's validation code. Copy the result, download it as a `.txt` file, or send it straight into another tool to keep working on it.