Movatterモバイル変換


[0]ホーム

URL:


💎 Zod 4 is now stable! Read the announcement.
Zod logoZod logo
Zod logoZod logo

Zod 4

Release notes

Migration guide

Documentation

Intro

Basic usage

Defining schemas

Customizing errors

Formatting errors

Metadata and registries

New

JSON Schema

New

Codecs

New

Ecosystem

For library authors

Packages

Zod

Zod Mini

New

Zod Core

New

github logo
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 now stable! Read therelease notes here.




Featured sponsor: Jazz

Jazz logo

Interested in featuring?Get in touch.

Introduction

Zod is a TypeScript-first validation library. Using Zod, you can defineschemas you can use to validate data, from a simplestring to a complex nested object.

import * as zfrom "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 onjsr.io.

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

Requirements

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

"strict"

You must enablestrict mode in yourtsconfig.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 theEcosystem page for a complete list of libraries that support Zod or are built on top of it.

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 aZod resolver
  • zshy - Originally created as Zod's internal build tool. Bundler-free, batteries-included build tool for TypeScript libraries. Powered bytsc.

Sponsors

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

Platinum

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

Cut code review time & bugs in half

coderabbit.ai


Gold

Courier logo (light theme)Courier logo (dark theme)

The API platform for sending notifications

courier.com
Liblab logo (light theme)Liblab logo (dark theme)

Generate better SDKs for your APIs

liblab.com
Neon logo (light theme)Neon logo (dark theme)

Serverless Postgres — Ship faster

neon.tech
Retool logo (light theme)Retool logo (dark theme)

Build AI apps and workflows with Retool AI

retool.com
Stainless logo (light theme)Stainless logo (dark theme)

Generate best-in-class SDKs

stainlessapi.com
Speakeasy logo (light theme)Speakeasy logo (dark theme)

SDKs & Terraform providers for your API

speakeasy.com

Silver


Bronze


Migration guide

Complete changelog and migration guide for upgrading from Zod 3 to Zod 4

Basic usage

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

On this page


[8]ページ先頭

©2009-2025 Movatter.jp