Skip to content
100% local

Zod schema to TypeScript type

Convert a Zod schema definition into its matching TypeScript interface or type.

Input
Output

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.

FAQ

Which Zod version does this support?
The common factory functions and chained methods from Zod v3 and v4 — objects, arrays, unions, records and the rest. Custom transforms and refinements are parsed and skipped, since their effect on the type cannot be inferred from the schema text alone.
What happens to .refine(), .transform() and similar calls?
They're recognized and ignored: the tool keeps the type the schema had before the call, since it can't evaluate an arbitrary function to know how a transform changes the shape.
Can it handle a schema split across multiple const declarations?
Yes. Every declared schema in the input is converted to its own interface or type, in the order it appears, so a shared sub-schema referenced by name in another one resolves correctly.
Why does my schema show an error instead of converting?
Usually a missing closing bracket, parenthesis or quote somewhere in the pasted code. Check that every z.object({ ... }) and array literal is properly closed.
Is my schema uploaded anywhere?
No. The conversion runs entirely in your browser — your schema never leaves your device.