Zod Mini is a lightweight alternative to the standard Zod library, introduced in Zod 4, that prioritizes minimal bundle size and full tree-shaking support.
Instead of the common method-chaining approach, Zod Mini provides a functional API that makes it easier for modern bundlers to eliminate unused code. This design is especially valuable for frontend applications where every kilobyte matters.
Core Features of Zod Mini
Import Path
Zod Mini is imported directly from "zod/mini"
. Zod Mini Docs
Functional API
- Regular Zod: z.string().optional().nullable()
- Zod Mini: z.nullable(z.optional(z.string()))
Bundle Size Optimisation
A simple schema such as z.boolean().parse(true)
is roughly 2.12 KB gzipped in Zod Mini versus 5.91 KB in the standard Zod build. Complex schemas amplify the savings further.
Validation Methods
All familiar parsing methods such as .parse()
, .safeParse()
, and their async equivalents remain available. Constraints like trimming, regex, and size checks are handled via .check()
.
Error Messages
Unlike regular Zod, Zod Mini does not include English locale messages by default. Without configuring a locale, errors are simplified to "Invalid input"
.
When to Choose Zod Mini
Best suited for:
- Frontend apps where bundle size and performance are critical.
- Deployments targeting low-bandwidth users or environments like edge functions.
- Projects with relatively straightforward schema validation requirements.
Less suitable for:
- Backends or serverless APIs where DX and readability are more important than size.
- Projects needing localized or descriptive error messages out of the box.
- Developers who prefer method-chaining syntax for better discoverability and autocomplete.
If developer experience and method chaining are more important than bundle size, regular Zod is the better choice.
Zod Mini vs Zod
Feature | Zod (Regular) | Zod Mini |
---|---|---|
API style | Method chaining | Functional (nested calls) |
Bundle size | Larger | ~60% smaller |
DX & Autocomplete | Strong | Limited |
Error messages | Full locales included | Defaults to "Invalid input" |
Best for | Backend / complex schemas | Frontend / size-sensitive apps |