Zod is a TypeScript-first schema declaration and validation library used for data validation in Javascript and Typescript applications. It allows developers to define schemas and validate data against them at runtime, ensuring type safety and data integrity. It was created by Colin McDonnell.
Zod is designed to be developer-friendly, aiming to eliminate duplicative type declarations. With Zod, you declare a validator once, and Zod automatically infers the static TypeScript type. Key features include zero dependencies, compatibility with Node.js and modern browsers, a tiny core bundle size (around 2kb gzipped), an immutable API, and built-in JSON schema conversion. It also offers static type inference, composability, expressive validation, and detailed error messages. Zod supports a wide variety of data types and validation rules, and allows for custom validation logic.
Zod is available as a free and open-source library. It can be installed using npm or yarn. Due to its capabilities, Zod has integrations with libraries and frameworks such as React Hook Form, Formik, tRPC, Next.js, and Remix.