💎 Zod 4.6 is out!  Read the announcement.
Zod logo
NewZod 4.6
Zod logo

Zod

TypeScript-first schema validation with static type inference
by @colinhacks


Zod CI statusCreated by Colin McDonnellLicensenpmstars
Website  •  Discord  •  𝕏  •  Bluesky

Zod 4 is stable. Read the release notes and migration guide.




Introduction

Zod is a TypeScript-first validation library. Using Zod, you can define schemas you can use to validate data, from a simple string to a complex nested object.

import * as z from "zod";
 
const User = z.object({
  name: z.string(),
});
 
// some untrusted data...
const input = { /* stuff */ };
 
// the parsed result is validated and type safe!
const data = User.parse(input);
 
// so you can use it with confidence :)
console.log(data.name);

Features

  • Zero external dependencies
  • Works in Node.js and all modern browsers
  • Tiny: 2kb core bundle (gzipped)
  • Immutable API: methods return a new instance
  • Concise interface
  • Works with TypeScript and plain JS
  • Built-in JSON Schema conversion
  • Extensive ecosystem

Installation