Kanon Bundle Size
Real numbers. No marketing fluff. Data auto-generated on Apr 3, 2026.
TL;DR
For a complete app with all schema types (gzip):
- Kanon : 4.22 kB baseline
- Zod 4 Mini : 7.50 kB (+78%)
- Zod 4 Classic : 27.57 kB (+554%)
Real-World Use Cases
These are actual validation scenarios you'll encounter in production:
| Use Case | Kanon v3 | Zod 4 Mini | Zod 4 Classic | Zod 3 |
|---|---|---|---|---|
Login Form Login form validation | 3.08 kB baseline | 4.29 kB +39% | 27.25 kB +784% | 12.83 kB +316% |
User Profile User profile with optional fields | 3.43 kB baseline | 5.17 kB +51% | 27.30 kB +697% | 12.87 kB +276% |
API Response API response with discriminated union | 3.47 kB baseline | 4.65 kB +34% | 27.27 kB +687% | 12.85 kB +271% |
Config Validation App configuration validation | 3.25 kB baseline | 5.06 kB +56% | 27.32 kB +742% | 12.89 kB +297% |
Form + Coercion Form data with type coercion | 3.22 kB baseline | 4.52 kB +41% | 27.39 kB +751% | 12.91 kB +301% |
Full App Complete app schemas (comprehensive) | 4.22 kB baseline | 7.50 kB +78% | 27.57 kB +554% | 13.09 kB +210% |
What each test validates
| Use Case | What it validates |
|---|---|
| Login Form | Email + password with constraints |
| User Profile | UUID, email, optional age, roles array |
| API Response | Discriminated union (success/error) |
| Config Validation | URL, port range, enum, optional timeout |
| Form + Coercion | String→Number, String→Boolean, String→Date |
| Full App | Everything above + discriminatedUnion, record, etc. |
Kanon Detailed Breakdown
| Use Case | Raw | Gzip | Brotli |
|---|---|---|---|
| Login Form Login form validation | 10.38 kB | 3.08 kB | 2.71 kB |
| User Profile User profile with optional fields | 11.65 kB | 3.43 kB | 3.00 kB |
| API Response API response with discriminated union | 11.81 kB | 3.47 kB | 3.05 kB |
| Config Validation App configuration validation | 10.81 kB | 3.25 kB | 2.85 kB |
| Form + Coercion Form data with type coercion | 11.08 kB | 3.22 kB | 2.84 kB |
| Full App Complete app schemas (comprehensive) | 14.44 kB | 4.22 kB | 3.74 kB |
Data generated on Apr 3, 2026
Why Kanon is Smaller: True Tree-Shaking
Kanon uses pure functions. Zod uses classes. This architectural difference is why Kanon tree-shakes perfectly.
// ✅ Kanon - each function is standalone
// Only string() and object() end up in your bundle
import { string, object, parse } from "@pithos/core/kanon";
const loginSchema = object({
email: string({ format: "email" }),
password: string({ minLength: 8 }),
});
// ⚠️ Zod - z is a namespace that carries ALL methods
// The entire Zod library ends up in your bundle
import { z } from "zod";
const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
});
Even z.string().min(1) pulls in ~27 kB because class methods are bundled together.
Zod 4 Mini: A Partial Solution
Zod 4 introduced zod/mini which is smaller, but still can't fully tree-shake:
| Scenario | Zod 4 Classic | Zod 4 Mini | Kanon v3 |
|---|---|---|---|
| Simple login form | ~27.2 kB | ~4.3 kB | ~3.1 kB |
| Full app schemas | ~27.6 kB | ~7.5 kB | ~4.2 kB |
| Growth rate | Almost flat | +75% | +37% |
Kanon v2.5.0 vs Zod v4.3.6
Kanon's bundle grows proportionally with usage. Zod's is mostly fixed overhead.
Convenience Helpers: k, z & validation
Kanon offers convenience helpers for different use cases, but they come with a trade-off:
| Import Style | Kanon v3 | Zod 4 Mini | Zod 4 Classic |
|---|---|---|---|
| Direct imports Always (production) | 3.08 kB baseline | 4.29 kB +39% | 27.25 kB +784% |
validation helper +3%validation(schema).safeParse(data) | 3.17 kB baseline | 4.29 kB +35% | 27.25 kB +758% |
k namespace +73%Zod-like syntax: k.string(), k.object()... | 5.33 kB baseline | 4.29 kB +-20% | 27.25 kB +411% |
z shim +119%Migrating from Zod | 6.75 kB baseline | 4.29 kB +-36% | 27.25 kB +304% |
Reproduce These Results
Want to verify these results? See how to reproduce our data.
Summary
| Aspect | Kanon | Zod |
|---|---|---|
| Architecture | Functions | Classes |
| Tree-shaking | ✅ Full | ❌ Limited |
| Min bundle | ~3 kB | ~4-27 kB |
| Scales with usage | ✅ Yes | ❌ Mostly fixed |
| Migration path | z shim available | N/A |
In production: Use direct imports for the smallest bundle.
Prototyping: Use k namespace for convenience.
Migrating from Zod: Use z shim, then gradually switch to direct imports.
Related
- Kanon vs Zod — Full comparison: philosophy, API, migration
- Zygos — Bundle Size — Result pattern size comparison
- Arkhe — Bundle Size — Utility function size comparison
- Kanon Module Guide — Full module documentation