Skip to content

Installation

Requirements

  • TypeScript 4.5+!
  • You must enable strict mode in your tsconfig.json. This is a best practice for all TypeScript projects.
json
{
  // ...
  "compilerOptions": {
    // ...
    "strict": true
  }
}
{
  // ...
  "compilerOptions": {
    // ...
    "strict": true
  }
}

From npm (Node/Bun)

sh
npm install zod
npm install zod
sh
yarn add zod
yarn add zod
sh
bun add zod
bun add zod
sh
pnpm add zod
pnpm add zod

Zod also publishes a canary version on every commit. To install the canary:

sh
npm install zod@canary
npm install zod@canary
sh
yarn add zod@canary
yarn add zod@canary
sh
bun add zod@canary
bun add zod@canary
sh
pnpm add zod@canary
pnpm add zod@canary

From 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.

Released under the MIT License.