Skip to main content

Package Manager Installation

Install Zod using your preferred package manager:
npm install zod

Requirements

Zod requires TypeScript 4.5+ for the best experience. You can use Zod with plain JavaScript, but you’ll miss out on static type inference.
  • TypeScript: 4.5 or higher (recommended)
  • Node.js: Works with all modern versions
  • Browsers: Works in all modern browsers

Runtime-Specific Setup

Node.js

Zod works out of the box with Node.js. Just import it in your code:
import * as z from "zod";

// or using CommonJS
const z = require("zod");

Deno

You can import Zod directly from npm in Deno:
import * as z from "npm:zod@latest";

const schema = z.string();
schema.parse("hello");
Deno has built-in TypeScript support, so you get full type inference without additional configuration.

Bun

Bun has native support for npm packages:
bun add zod
Then import as usual:
import * as z from "zod";

const schema = z.number();
schema.parse(42);

Verify Installation

Create a simple test file to verify Zod is installed correctly:
test.ts
import * as z from "zod";

const schema = z.string();

try {
  const result = schema.parse("hello");
  console.log("Success:", result);
} catch (error) {
  console.error("Error:", error);
}
Run the file:
node test.ts
You should see:
Success: hello

Next Steps

Quick Start Tutorial

Learn the fundamentals with a hands-on tutorial

Build docs developers (and LLMs) love