GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing zod.dev — Intro | Zod

Zod logoZod logo

Documentation

Intro

Basic usage

Defining schemas

Customizing errors

Formatting errors

Metadata and registries

JSON Schema

Codecs

AOT compilation

Ecosystem

For library authors

Packages

Zod

Zod Mini

Zod Core

Blog

Zod 4.6

Zod 4.5

Reducing Zod's memory footprint by an order of magnitude with method memoization

View all

NewZod 4.6
Zod logoZod 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

npm install zod

Zod is also available as @zod/zod on jsr.io.

Zod provides an MCP server that can be used by agents to search Zod's docs. To add to your editor, follow these instructions. Zod also provides an llms.txt file.

Requirements

Zod is tested against TypeScript v5.5 and later. Older versions may work but are not officially supported.

"strict"

You must enable strict mode in your tsconfig.json. This is a best practice for all TypeScript projects.

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

Ecosystem

Zod has a thriving ecosystem of libraries, tools, and integrations. Refer to the Ecosystem page for a complete list of libraries that support Zod or are built on top of it.

  • Resources
  • API Libraries
  • Form Integrations
  • Zod to X
  • X to Zod
  • Mocking Libraries
  • Powered by Zod

I also contribute to the following projects, which I'd like to highlight:

  • tRPC - End-to-end typesafe APIs, with support for Zod schemas
  • React Hook Form - Hook-based form validation with a Zod resolver
  • zshy - Originally created as Zod's internal build tool. Bundler-free, batteries-included build tool for TypeScript libraries. Powered by tsc.

Sponsors

Sponsorship at any level is appreciated and encouraged. If you built a paid product using Zod, consider one of the corporate tiers.

Platinum

Trigger.dev logo (dark theme)Trigger.dev logo (light theme)

Build and deploy fully-managed AI agents and workflows

trigger.dev


Gold

CodeRabbit logo (light theme)CodeRabbit logo (dark theme)

Cut code review time & bugs in half

coderabbit.ai

Silver

Subtotal logosubtotal.com
PropelAuth logopropelauth.com
Scalar logoscalar.com
Transloadit logotransloadit.com
Whop logowhop.com
Inngest logoinngest.com
Storyblok logostoryblok.com
Mux logomux.link/zod
Cybozu logocybozu.co.jp
9thCO logo9thco.com
StackBlitz logostackblitz.com

Bronze

Code for Japan logocode4japan.org
Jason Laster logogithub.com/jasonLaster
Convex logoconvex.dev
n8n logon8n.io
Route4Me logoroute4me.com

Basic usage

Basic usage guide covering schema definition, parsing data, error handling, and type inference

On this page

Introduction
Features
Installation
Requirements
"strict"
Ecosystem
Sponsors
Platinum
Gold
Silver
Bronze
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.