Introduction
zod-to-form is schema-driven form generation for Zod v4. Walk a Zod schema once — render a validated form at runtime, or generate a static hand-readable .tsx component at build time.
import { ZodForm } from '@zod-to-form/react';
<ZodForm schema={userSchema} onSubmit={(data) => console.log(data)}>
<button type="submit">Submit</button>
</ZodForm>
When to Use Which Path
| Path | Choose when |
|---|---|
Runtime (<ZodForm>) | Schemas change frequently, rapid prototyping, admin/CRUD, instant feedback |
CLI (zodform generate) | Production forms, design-system integration, zero runtime dep on zod-to-form, code should be inspectable and committed |
Both paths share @zod-to-form/core — the same walker produces the same FormField[] tree. A component config file can drive both paths to produce functionally identical forms.
Packages
| Package | Description |
|---|---|
@zod-to-form/core | Schema walker & processor registry — zero runtime deps |
@zod-to-form/react | <ZodForm> runtime renderer + shadcn/ui component map |
@zod-to-form/cli | zodform generate CLI for static codegen |
@zod-to-form/codegen | Codegen primitives shared by the CLI |
Features
- Zod v4 native introspection — reads
_zod.def,_zod.bag,.meta(), andz.registry()directly - Runtime rendering —
<ZodForm>reads schemas at render time for instant iteration - CLI codegen —
npx zodform generateproduces static.tsxfiles with zero runtime dependency - Shared component config — one config drives both CLI and runtime identically
- AOT validation optimization — progressive L1/L2/L3 rewrites decompose per-field Zod calls, extract native RHF rules, and lift cross-field refines into real-time feedback (see AOT Optimization)
- Supports all major Zod types — nested objects (fieldsets), arrays (repeaters), discriminated unions (variant reveal), plus
bigint,nativeEnum,record,map,set,transform, andrefine - Zero-dependency core —
@zod-to-form/corehas no runtime dependencies (Zod is a peer)
Next Steps
- Quickstart — install and render your first form
- Runtime Rendering —
<ZodForm>anduseZodForm - CLI Codegen —
zodform generateworkflow - AOT Optimization — L1/L2/L3 validation rewrites and custom optimizers
- API Reference — auto-generated from source
Roadmap
- Vite plugin — auto-regenerate forms on schema change, HMR-aware, no CLI step
- Studio — four-quadrant IDE: schema editor, live form preview, config editor, code output
- Standard Schema adapters — reuse the processor registry to support Valibot, ArkType, and Standard Schema
- zod-aot integration —
--aotflag that uses zod-aot compiled validators forschemaLitesubmit-time validation - L3 cross-field analysis — static analysis of
superRefinebodies to auto-convert towatch()+validate