Validation Generator
Generate a Yup or Zod schema
Fields
Validation schema
Pick Yup or Zod, add your fields, then click “Generate”: the schema will appear here.
About this tool
This tool writes the validation schema for a form using Zod or Yup, two of the most widely used validation libraries in TypeScript projects. It saves you from retyping the same rules for every sign-up, contact or checkout form, and gives you a clean starting point to refine in your React, Next.js or Node project.
Each field gets a name and a type: string, number, boolean, date, URL or email. You can mark it as required and set a minimum and a maximum, which apply to the text length for strings and to the value for numbers. The generated code includes the import, the schema object and a Schema type inferred with z.infer or yup.InferType.
How to use it
- Choose Yup or Zod in “Select Library”.
- Click “Add Field”, then fill in “Field Name” and “Field Type”.
- Check “Required”, “Min” or “Max” as needed and enter the values.
- Click “Generate Schema”, then “Copy” to grab the code.
Frequently asked questions
Do Min and Max apply to every field type?
No. For strings, URLs and emails they limit the text length; for numbers they bound the value. They are ignored for booleans and dates. The tool also flags a minimum that is greater than the maximum.
How are optional fields handled?
With Zod, a field without “Required” gets .optional(); with Yup, only required fields get .required(), since Yup treats fields as optional by default. Dates use z.coerce.date() in Zod, so a date string is accepted too.
Is the schema generated by AI?
No. The code is built directly from the fields you enter using fixed rules, so the same form always produces the same schema. Generation happens in your browser, with no server call.
Can I get the TypeScript type for the form?
Yes. The code ends with export type Schema, inferred from the schema with z.infer for Zod or yup.InferType for Yup. You can type your form values without writing the interface by hand.