Zod
Zod validates data at runtime and infers TypeScript types from your schemas. Define the shape once, get both validation and types.
Overview
- What: Schema validation library for TypeScript/JavaScript
- Install:
npm install zod - Key feature:
z.infer<typeof Schema>gives you the TypeScript type for free - Use cases: Form validation, API response validation, environment variable parsing
- Size: ~13KB minified
Contents
- Concepts - How Zod works
- Schemas - Defining shapes, nesting, composing
- Quickstart - Get started
- Basic Usage - Define, validate, infer types
- Deep Dives - Advanced patterns
- Notes - Tips and gotchas