Skip to main content

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

PathChoose 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

PackageDescription
@zod-to-form/coreSchema walker & processor registry — zero runtime deps
@zod-to-form/react<ZodForm> runtime renderer + shadcn/ui component map
@zod-to-form/clizodform generate CLI for static codegen
@zod-to-form/codegenCodegen primitives shared by the CLI

Features

  • Zod v4 native introspection — reads _zod.def, _zod.bag, .meta(), and z.registry() directly
  • Runtime rendering<ZodForm> reads schemas at render time for instant iteration
  • CLI codegennpx zodform generate produces static .tsx files 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, and refine
  • Zero-dependency core@zod-to-form/core has no runtime dependencies (Zod is a peer)

Next Steps

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--aot flag that uses zod-aot compiled validators for schemaLite submit-time validation
  • L3 cross-field analysis — static analysis of superRefine bodies to auto-convert to watch() + validate