Kanon Bundle Size
Real numbers. No marketing fluff. Data auto-generated on Feb 27, 2026.
TL;DR
For a complete app with all schema types (gzip):
- Kanon : 4.19 kB baseline
- Zod 4 Mini : 9.57 kB (+128%)
- Zod 4 Classic : 17.24 kB (+311%)
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.06 kB baseline | 6.71 kB +119% | 14.72 kB +381% | 12.80 kB +318% |
User Profile User profile with optional fields | 3.40 kB baseline | 7.53 kB +121% | 15.88 kB +367% | 12.84 kB +277% |
API Response API response with discriminated union | 3.44 kB baseline | 7.00 kB +103% | 15.96 kB +364% | 12.82 kB +272% |
Config Validation App configuration validation | 3.23 kB baseline | 7.35 kB +128% | 15.90 kB +393% | 12.86 kB +298% |
Form + Coercion Form data with type coercion | 3.20 kB baseline | 6.91 kB +116% | 16.14 kB +405% | 12.88 kB +303% |
Full App Complete app schemas (comprehensive) | 4.19 kB baseline | 9.57 kB +128% | 17.24 kB +311% | 13.06 kB +211% |
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.06 kB | 2.71 kB |
| User Profile User profile with optional fields | 11.65 kB | 3.40 kB | 3.00 kB |
| API Response API response with discriminated union | 11.81 kB | 3.44 kB | 3.03 kB |
| Config Validation App configuration validation | 10.81 kB | 3.23 kB | 2.85 kB |
| Form + Coercion Form data with type coercion | 11.08 kB | 3.20 kB | 2.84 kB |
| Full App Complete app schemas (comprehensive) | 14.44 kB | 4.19 kB | 3.72 kB |
Data generated on Feb 27, 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/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 ~15 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 | ~14.7 kB | ~6.7 kB | ~3.1 kB |
| Full app schemas | ~17.2 kB | ~9.6 kB | ~4.2 kB |
| Growth rate | +17% | +43% | +37% |
Kanon v2.0.1 vs Zod v4.3.5
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.06 kB baseline | 6.71 kB +119% | 14.72 kB +381% |
validation helper +3%validation(schema).safeParse(data) | 3.14 kB baseline | 6.71 kB +114% | 14.72 kB +369% |
k namespace +74%Zod-like syntax: k.string(), k.object()... | 5.32 kB baseline | 6.71 kB +26% | 14.72 kB +177% |
z shim +119%Migrating from Zod | 6.71 kB baseline | 6.71 kB +-0% | 14.72 kB +119% |
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 | ~7-15 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