SponsorsTable of ContentsGetting StartedInstallationMigration guide
Usage
CoerceLiteralsStringsNumbersBigIntsNaNsBooleansDatesEnumsOptionalsNullablesObjectsArraysUnionsRecordsMapsSetsIntersectionsRecursive typesPromisesInstanceofFunctionsPreprocess
Schema methods
Custom schemas
Guides and Concepts
Error HandlingComparisonEcosystem
Contributing
ChangelogCode of ConductLICENSE
Links
Clerk
⌘+J

© 2025 Zod


Designed in Earth-616

Build by oeri

Installation

NPM DENO jsdelivr


Requirements

Before installing zod, make sure your environment meets the following requirements:

  • TypeScript 4.5+ (Recommended for type safety and best performance).
  • Enable strict mode in your tsconfig.json (Best practice for TypeScript projects).

TypeScript Configuration

Modify your tsconfig.json to enable strict mode:

tsconfig.json
{
  "compilerOptions": {
    "strict": true
  }
}

Via Package Managers

To install zod in your project, use one of the following package managers:

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

Canary Version

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

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

The rest of this README assumes you are using npm and importing directly from the "zod" package.


Using a CDN

For quick usage in the browser without installing dependencies, you can include zod from a CDN:

UMD (Global Script)

<!-- Load the minified version from jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/zod@latest/lib/index.min.js"></script>

ESM (Module Import)

<script type="module">
  import zod from "https://cdn.jsdelivr.net/npm/zod@latest/+esm";
</script>

Note:

  • The UMD version loads zod as a global variable.
  • The ESM version allows importing as a module in modern browsers.

Now you are ready to start using zod! 🚀

On This Page

Installation
Requirements
Typescript configuration
Via package managers
Canary version
Using a cdn
Umd (global script)
Esm (module import)

Edit this page on GitHub