Installation
Requirements
- TypeScript 4.5+!
- You must enable
strictmode in yourtsconfig.json. This is a best practice for all TypeScript projects.
json
{
// ...
"compilerOptions": {
// ...
"strict": true
}
}{
// ...
"compilerOptions": {
// ...
"strict": true
}
}From npm (Node/Bun)
sh
npm install zodnpm install zodsh
yarn add zodyarn add zodsh
bun add zodbun add zodsh
pnpm add zodpnpm add zodZod also publishes a canary version on every commit. To install the canary:
sh
npm install zod@canarynpm install zod@canarysh
yarn add zod@canaryyarn add zod@canarysh
bun add zod@canarybun add zod@canarysh
pnpm add zod@canarypnpm add zod@canaryFrom deno.land/x (Deno)
Unlike Node, Deno relies on direct URL imports instead of a package manager like NPM. Zod is available on deno.land/x. The latest version can be imported like so:
ts
import { z } from "https://deno.land/x/zod/mod.ts";import { z } from "https://deno.land/x/zod/mod.ts";You can also specify a particular version:
ts
import { z } from "https://deno.land/x/zod@v3.16.1/mod.ts";import { z } from "https://deno.land/x/zod@v3.16.1/mod.ts";The rest of this README assumes you are using npm and importing directly from the
"zod"package.