Source URL: https://zod.dev/llms.txt
Section titled “Zod > Zod is a TypeScript-first schema validation library with static type inference. This documentation provides comprehensive coverage of Zod 4’s features, API, and usage patterns. ## Defining schemas - Defining schemas: Complete API reference for all Zod schema types, methods, and validation features - Primitives - Coercion - Literals - Strings - String formats - Emails - UUIDs - URLs - ISO datetimes - ISO dates - ISO times - IP addresses - IP blocks (CIDR) - MAC Addresses - JWTs - Hashes - Custom formats - Template literals - Numbers - Integers - BigInts - Booleans - Dates - Enums - .enum - .exclude() - .extract() - Stringbools - Optionals - Nullables - Nullish - Unknown - Never - Objects - z.strictObject - z.looseObject - .catchall() - .shape - .keyof() - .extend() - .safeExtend() - .pick() - .omit() - .partial() - .required() - Recursive objects - Circularity errors - Arrays - Tuples - Unions - Exclusive unions (XOR) - Discriminated unions - Intersections - Records - z.record - z.partialRecord - z.looseRecord - Maps - Sets - Files - Promises - Instanceof - Property - Refinements - .refine() - error - abort - path - when - .superRefine() - .check() - Codecs - Pipes - Transforms - .transform() - .preprocess() - Defaults - Prefaults - Catch - Branded types - Readonly - JSON - Functions - Custom - Apply ## Basic usage - Basic usage: Basic usage guide covering schema definition, parsing data, error handling, and type inference - Defining a schema - Parsing data - Handling errors - Inferring types ## Codecs - Codecs: Bidirectional transformations with encode and decode - Composability - Type-safe inputs - Async and safe variants - How encoding works - Codecs - Pipes - Refinements - Defaults and prefaults - Catch - Stringbool - Transforms - Useful codecs - stringToNumber - stringToInt - stringToBigInt - numberToBigInt - isoDatetimeToDate - epochSecondsToDate - epochMillisToDate - json(schema) - utf8ToBytes - bytesToUtf8 - base64ToBytes - base64urlToBytes - hexToBytes - stringToURL - stringToHttpURL - uriComponent ## Ecosystem - Ecosystem: Overview of the Zod ecosystem including integrations, tools, and community resources - Resources - API Libraries - Form Integrations - Zod to X - X to Zod - Mocking Libraries - Powered by Zod - Zod Utilities ## Customizing errors - Customizing errors: Guide to customizing validation error messages and error handling patterns - The error param - Per-parse error customization - Include input in issues - Global error customization - Internationalization - Locales - Error precedence ## Formatting errors - Formatting errors: Utilities for formatting and displaying Zod errors - z.treeifyError() - z.prettifyError() - z.formatError() - z.flattenError() ## Intro - Intro: Introduction to Zod - TypeScript-first schema validation library with static type inference - Introduction - Features - Installation - Requirements - “strict” - Ecosystem - Sponsors - Platinum - Gold - Silver - Bronze ## JSON Schema - JSON Schema: How to convert Zod schemas to JSON Schema - z.fromJSONSchema() - z.toJSONSchema() - io - target - metadata - unrepresentable - cycles - reused - override - Conversion - String formats - Numeric types - Object schemas - File schemas - Nullability - Registries ## For library authors - For library authors: Guidelines and best practices for library authors integrating with Zod - Do I need to depend on Zod? - How to configure peer dependencies? - How to support Zod 4? - Do I need to publish a new major version? - How to support Zod 3 and Zod 4 simultaneously? - How to support Zod and Zod Mini simultaneously? - How to accept user-defined schemas? ## Metadata and registries - Metadata and registries: Attaching and manipulatinvg metadata on Zod schemas - Registries - .register() - Metadata - z.globalRegistry - .meta() - .describe() - Custom registries - Referencing inferred types - Constraining schema types ## Joining Clerk as an OSS Fellow to work on Zod 4 - Joining Clerk as an OSS Fellow to work on Zod 4: Announcing my Clerk OSS Fellowship and what’s coming in Zod 4. - On deck: Zod 4 - Zod’s current funding story - The Clerk fellowship - OSS, funding models, and trying new things ## Zod Core - Zod Core: Zod Core package - minimal core functionality for custom implementations - Schemas - Internals - Parsing - Checks - Errors - Issues ## Zod Mini - Zod Mini: Zod Mini - a tree-shakable Zod - Tree-shaking - When (not) to use Zod Mini - DX - Backend development - Internet speed - ZodMiniType - .parse - .check() - .register() - .brand() - .clone(def) - No default locale ## Zod - Zod: Internals and structure of the Zod library ## Migration guide - Migration guide: Complete changelog and migration guide for upgrading from Zod 3 to Zod 4 - Error customization - deprecates message parameter - drops invalid_type_error and required_error - drops errorMap - ZodError - updates issue formats - changes error map precedence - deprecates .format() - deprecates .flatten() - drops .formErrors - deprecates .addIssue() and .addIssues() - z.number() - no infinite values - .safe() no longer accepts floats - .int() accepts safe integers only - z.string() updates - deprecates .email() etc - stricter .uuid() - no padding in .base64url() - drops z.string().ip() - updates z.string().ipv6() - drops z.string().cidr() - z.coerce updates - .default() updates - z.object() - defaults applied within optional fields - deprecates .strict() and .passthrough() - deprecates .strip() - drops .nonstrict() - drops .deepPartial() - changes z.unknown() optionality - deprecates .merge() - z.nativeEnum() deprecated - z.array() - changes .nonempty() type - z.promise() deprecated - z.function() - adds .implementAsync() - .refine() - ignores type predicates - drops ctx.path - drops function as second argument - z.ostring(), etc dropped - z.literal() - drops symbol support - static .create() factories dropped - z.record() - drops single argument usage - improves enum support - z.intersection() - throws Error on merge conflict - Internal changes - updates generics - adds z.core - moves ._def - drops ZodEffects - adds ZodTransform - drops ZodPreprocess - drops ZodBranded ## Release notes - Release notes: Zod 4 release notes and new features including performance improvements and breaking changes - Versioning - Why a new major version? - Benchmarks - 14x faster string parsing - 7x faster array parsing - 6.5x faster object parsing - 100x reduction in tsc instantiations - 2x reduction in core bundle size - Introducing Zod Mini - 6.6x reduction in core bundle size - Metadata - The global registry - .meta() - JSON Schema conversion - Recursive objects - File schemas - Internationalization - Error pretty-printing - Top-level string formats - Custom email regex - Template literal types - Number formats - Stringbool - Simplified error customization - Upgraded z.discriminatedUnion() - Multiple values in z.literal() - Refinements live inside schemas - .overwrite() - An extensible foundation: zod/v4/core - Wrapping up ## Versioning - Versioning: Versioning strategy and compatibility information for Zod 4 - Update — July 8th, 2025 - Versioning in Zod 4 - Why? - Why can’t libraries just support v3 and v4 simultaneously? --- This documentation covers Zod v4, a TypeScript-first schema validation library. Use the URLs above to access specific pages and sections for detailed information about schema definition, validation, error handling, and advanced patterns.”