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

Table of Contents


  • Sponsors
    • Diamond
    • Platinum
    • Gold
    • Silver
    • Bronze
  • Getting Started
    • Introduction
      • What Zod can do
      • How Can Zod Help You
    • Why Use Zod
    • Core Features
    • Next Steps
    • Contributing
  • Installation
    • Requirements
      • TypeScript Configuration
    • Via Package Managers
      • Canary Version
    • Using a CDN
      • UMD (Global Script)
      • ESM (Module Import)
  • Migration guide
    • Upgrading from Zod → Zod 2
      • New features
      • Breaking changes
    • Upgrading from Zod → Zod 3
      • New features
      • Breaking changes
  • Usage
    • Basic Usage
      • Creating a Simple String Schema
      • Parsing Values
    • Defining Object Schemas
      • Parsing an Object
      • Inferring TypeScript Types
    • Primitive Types in Zod
    • Handling Special Types
      • Empty Types
      • Catch-All Types
      • Never Type
    • Advanced Schema Composition
      • Array Schema
      • Tuple Schema
      • Union Types
      • Intersection Types
    • Optional and Nullable Fields
      • Making a Field Optional
      • Allowing Null Values
    • Refining and Custom Validations
      • Using .refine() for Custom Validation
      • Using .superRefine() for More Complex Validations
    • Transforming Data
    • Asynchronous Validations
    • Conclusion
  • Coercion
    • Coercion for primitives
  • Literals
  • Strings
    • Datetimes
    • Dates
    • Times
    • IP addresses
    • IP ranges (CIDR)
  • Numbers
  • BigInts
  • NaNs
  • Booleans
  • Dates
    • Validate Date Instances
    • Coercion to Date
  • Enums
    • Zod enums
      • Enum
      • Exclude/Extract
    • Native enums
      • Numeric enums
      • String enums
      • Const enums
  • Optionals
  • Nullables
  • Objects
    • .shape
    • .keyof
    • .extend
    • .merge
    • .pick/.omit
    • .partial
    • .deepPartial
    • .required
    • .passthrough
    • .strict
    • .strip
    • .catchall
  • Arrays
    • .element
    • .nonempty
    • .min/.max/.length
    • Unions
    • Discriminated unions
  • Records
  • Maps
  • Sets
  • Intersections
  • Recursive types
    • ZodType with ZodEffects
    • JSON type
    • Cyclical objects
  • Promises
  • Instanceof
  • Functions
  • Preprocess
  • Schema Methods
    • .parse
    • .parseAsync
    • .safeParse
    • .safeParseAsync
    • .refine
      • Arguments
      • Customize error path
      • Asynchronous refinements
      • Relationship to transforms
    • .superRefine
      • Abort early
      • Type refinements
    • .transform
      • Chaining order
      • Validating during transform
      • Relationship to refinements
      • Async transforms
    • .default
    • .describe
    • .catch
    • .optional
    • .nullable
    • .nullish
    • .array
    • .promise
    • .or
    • .and
    • .brand
    • .readonly
    • .pipe
      • Fix common issues with z.coerce.
  • Custom schemas
  • Guides and concepts
    • Type inference
    • Writing generic functions
      • Inferring the inferred type
      • Constraining allowable inputs
    • Error handling
    • Error formatting
  • ERROR_HANDLING in Zod
    • ZodError
    • ZodIssue
    • ZodIssueCode
    • ZodParsedType
    • A demonstrative example
    • Customizing errors with ZodErrorMap
    • Error map priority
      • Global error map
      • Schema-bound error map
      • Contextual error map
    • A working example
    • Error handling for forms
      • Formatting errors
      • Flattening errors
      • Post-processing issues
      • Extract type signature
  • Comparison
    • Joi
    • Yup
    • io-ts
    • Runtypes
    • Ow
    • Ecosystem
    • Resources
    • API libraries
    • Form integrations
    • Zod to X
    • X to Zod
    • Mocking
    • Powered by Zod
    • Utilities for Zod
  • Contributing
    • Initial steps
    • Development
    • Alternative VSCode Dev Container setup
      • Commands
      • Tests
      • Documentation
    • License
  • Changelog
    • Previous Releases
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.0.0-beta.1
      • 3.0.0-alpha.33
      • 3.0.0-alpha.32
      • 3.0.0-alpha.30
      • zod@3.0.0-alpha.24
      • zod@3.0.0-alpha.9
      • zod@3.0.0-alpha.8
      • zod@3.0.0-alpha.5
      • zod@3.0.0-alpha.4
      • zod@2
      • zod@1.11
      • zod@1.10
      • zod@1.9
      • zod@1.8
      • zod@1.7
      • zod@1.5
      • zod@1.4
      • zod@1.3
      • zod@1.2.6
      • zod@1.2.5
      • zod@1.2.3
      • zod@1.2.0
      • zod@1.1.0
      • zod@1.0.11
      • zod@1.0.10
      • zod@1.0.4
      • zod@1.0.2
      • zod@1.0.0
  • Code of Conduct
    • Our Pledge
    • Our Standards
    • Enforcement Responsibilities
    • Scope
    • Enforcement
    • Enforcement Guidelines
      • 1. Correction
      • 2. Warning
      • 3. Temporary Ban
      • 4. Permanent Ban
    • Attribution
  • License
  • Links
    • Repository
    • Installation
    • Bundles
    • Score and Test
    • UI

On This Page

Table of contents

Edit this page on GitHub