Zod to TypeScript
Turn Zod schemas into the TypeScript types they describe, like z.infer: objects, arrays, unions, enums and optional fields. Private.
Zod schema
Stays in your browserTypeScript
The result appears here after you press Convert.
Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)
Free Online Zod to TypeScript
Paste Zod schema code and see the TypeScript type it gives, without running anything. Schemas that refer to each other are handled. It gives developers a quick browser-based way to solve a focused zod to typescript task before moving the result into a project.
How to use Zod to TypeScript
Paste your code in the box on the left, or open a file, then press Convert. The result is the output type, as z.infer would give: a field with a default is required, and one marked optional gets a question mark.
Common mistakes
- Expecting z.input: the result is the output type, where defaults are already applied.
- Pasting schemas that depend on other files: add them to the box so the names can be resolved.
Frequently asked questions
Is my code run?
No. The code is only read by a small parser and never evaluated, so nothing you paste can run in your browser.
Why use this if I have z.infer?
z.infer works inside your project. This shows the written-out type, for documentation, for code that cannot import the schema, or to see exactly what the schema allows.
What if a schema uses transform or refine?
refine, min, max, email and similar checks do not change the type. transform changes the output, which cannot be known from the text, so it becomes unknown and you get a warning.
Is my code uploaded anywhere?
No. The conversion runs in your browser and nothing you paste is sent to a server.
How do I use this zod to typescript tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.
More Formatters & Parsers
JSON ParserCheck if JSON is valid and see it neatlyJSON Schema ValidatorCheck data follows the rules you setJSONPath TesterPick values out of JSON with a pathXML/XSD ValidatorCheck XML is valid and follows a schemaJSON ↔ TOML ConverterSwitch config files between JSON and TOMLURL ParserBreak a web link into its partsQuery String ParserRead the ?a=1&b=2 part of a linkREST API TesterSend API requests and see the response