This document covers the Zod Mini API (zod/mini), a tree-shakable, functional variant of Zod introduced in v4. Zod Mini provides identical validation functionality to the Classic API but uses a functional programming style that enables significantly better dead-code elimination by modern bundlers.
For information about the standard method-chaining API, see Classic API (zod). For low-level primitives shared by both APIs, see Core Package (zod/v4/core).
Sources: packages/docs/content/packages/mini.mdx1-11 packages/zod/package.json38-95
Zod Mini is available via the zod/mini export:
The Mini API can also be accessed via zod/v4/mini, which is functionally identical:
Sources: packages/zod/package.json60-64 packages/zod/package.json90-94
The primary difference between Zod Mini and Zod Classic is the programming paradigm: Mini uses functions where Classic uses methods.
Diagram: Classic vs Mini API Patterns
Classic API (method chaining):
Mini API (functional composition):
The functional approach allows bundlers to eliminate unused functions, whereas method implementations cannot be tree-shaken even if never called. All methods in packages/zod/src/v4/classic/schemas.ts156-259 are bundled regardless of usage, while functions in packages/zod/src/v4/mini/index.ts are only included when imported.
Sources: packages/docs/content/packages/mini.mdx25-47 packages/zod/src/v4/classic/schemas.ts156-259 packages/zod/src/v4/mini/schemas.ts43-79
.check() MethodIn Classic Zod, validation constraints are added via dedicated methods like .min(), .max(), .email(). In Mini, these constraints are passed as arguments to the .check() method defined in packages/zod/src/v4/mini/schemas.ts56-69
The .check() method accepts either:
z.minLength(), z.positive(), etc.)CheckFn<T> from packages/zod/src/v4/core/schemas.ts41String validation:
Number validation:
Custom check functions:
The .check() method is type-safe; TypeScript will prevent adding checks incompatible with the schema type. Check instances are stored in the schema's def.checks array as defined in packages/zod/src/v4/core/schemas.ts88
Sources: packages/docs/content/packages/mini.mdx131-198 packages/zod/src/v4/mini/schemas.ts56-69 packages/zod/src/v4/core/schemas.ts41 packages/zod/src/v4/core/schemas.ts88
Zod Mini exports a comprehensive set of validation functions. These functions return check objects that can be passed to .check().
Applied to number and bigint schemas:
z.lt(value) - less thanz.lte(value) / z.maximum(value) - less than or equalz.gt(value) - greater thanz.gte(value) / z.minimum(value) - greater than or equalz.positive() - greater than 0z.negative() - less than 0z.nonpositive() - less than or equal to 0z.nonnegative() - greater than or equal to 0z.multipleOf(value) - divisible by valueApplied to collections (array, set, map) and file schemas:
z.maxSize(value) - maximum sizez.minSize(value) - minimum sizez.size(value) - exact sizeApplied to string and array schemas:
z.maxLength(value) - maximum lengthz.minLength(value) - minimum lengthz.length(value) - exact lengthApplied to string schemas:
z.regex(pattern) - matches regular expressionz.lowercase() - validates all lowercasez.uppercase() - validates all uppercasez.includes(value) - contains substringz.startsWith(value) - starts with substringz.endsWith(value) - ends with substringz.refine(fn) - custom validation functionz.check(fn) - replaces .superRefine() from Classic APIThese modify data during validation but do not change inferred types:
z.overwrite(fn) - transforms valuez.normalize() - Unicode normalizationz.trim() - removes whitespacez.toLowerCase() - converts to lowercasez.toUpperCase() - converts to uppercaseRegister schema metadata in z.globalRegistry:
z.meta(metadata) - register metadata objectz.describe(description) - register description stringz.property(key, schema) - validates object propertyz.mime(value) - validates file MIME typeSources: packages/docs/content/packages/mini.mdx156-198
All Zod Mini schemas extend the ZodMiniType base class defined in packages/zod/src/v4/mini/schemas.ts7-38 which provides a minimal but powerful set of methods.
Diagram: Mini API Class Hierarchy
The ZodMiniType interface extends $ZodType with these methods:
Defined in packages/zod/src/v4/mini/schemas.ts52-55:
Defined in packages/zod/src/v4/mini/schemas.ts56-70:
inst.clone = (_def, params) => core.clone(inst, _def, params); - line 71inst.brand = () => inst as any; - line 72inst.apply = (fn) => fn(inst); - line 77Sources: packages/zod/src/v4/mini/schemas.ts7-79 packages/zod/src/v4/core/schemas.ts174-315
Zod Mini achieves significant bundle size reductions through aggressive tree-shaking.
| Schema Complexity | Zod Mini (gzip) | Zod Classic (gzip) | Reduction |
|---|---|---|---|
| Boolean parsing | 2.12kb | 5.91kb | 64% |
| Object with primitives | 4.0kb | 13.1kb | 69% |
The 5-10kb difference is meaningful primarily for:
Sources: packages/docs/content/packages/mini.mdx36-80
Unlike Classic Zod, Mini does not automatically load the English locale. All validation errors default to "Invalid input".
To enable localized error messages:
This configuration applies globally to all schemas.
Zod provides 40+ language locales via the zod/v4/locales export. The locale system is shared between Classic and Mini APIs.
For complete locale documentation, see Error Customization and Internationalization.
Sources: packages/docs/content/packages/mini.mdx231-244 packages/zod/package.json102-107
| Factor | Classic | Mini |
|---|---|---|
| Bundle size | ~13-17kb | ~4-6kb |
| DX (discoverability) | Excellent | Good |
| DX (verbosity) | Low | Higher |
| Tree-shaking | Minimal | Excellent |
| Backend use | Ideal | Overkill |
| Frontend use | Default choice | Size-constrained |
| Mobile 3G | Adequate | Preferred |
Sources: packages/docs/content/packages/mini.mdx82-109
Zod Mini builds on the zod/v4/core package, which provides low-level primitives shared by both Classic and Mini APIs.
Diagram: Core, Mini, and Classic Layering
| Feature | Core Package | Zod Mini |
|---|---|---|
| Base class | $ZodType schemas.ts174-184 | ZodMiniType extends $ZodType mini/schemas.ts7-38 |
| API style | Constructor system only | Functional API + .check() |
| Schema creation | new $ZodString.init() | z.string() mini/index.ts |
| Parsing | parse(schema, data) parse.ts15 | schema.parse(data) mini/schemas.ts52 |
| Checks | $ZodCheck interface checks.ts22 | Check factory functions mini/checks.ts |
| Error handling | $ZodError class errors.ts296 | Same, re-exported |
| Locales | Not included | Must be loaded via z.config() |
Both Mini and Classic schemas contain a ._zod property defined in packages/zod/src/v4/core/schemas.ts91-161:
The _zod.def property stores the schema definition:
For details on the core architecture, see Core Package (zod/v4/core).
Sources: packages/zod/src/v4/core/schemas.ts91-161 packages/zod/src/v4/mini/schemas.ts7-79 packages/zod/src/v4/classic/schemas.ts20-259 packages/docs/content/packages/core.mdx9-38
Sources: packages/zod/package.json60-64 packages/docs/content/packages/mini.mdx14-23
Refresh this wiki