Skip to content
/ supazod Public

Generate Zod schemas from Supabase CLI generated types

License

Notifications You must be signed in to change notification settings

dohooo/supazod

Repository files navigation

Supazod logo

Supazod

Generate Zod schemas from Typescript types generated by the Supabase CLI.

Usage

$ pnpm add --D supazod
$ supabase gen types typescript --local > types.ts
$ pnpm supazod -i types.ts -o schemas.ts -t schemas.d.ts -s public,schema_a,schema_b

That's it! Check your schemas.ts file - you should have Zod schemas generated for all your tables, views, enums and functions.

CLI Options

supazod [options]

-i, --input <path>         Input TypeScript file
-o, --output <path>        Output Zod schemas file
-t, --types-output <path>  Output type definitions (optional, defaults to no file)
-s, --schema <name>        Schema to process (optional, defaults to all)
--verbose                  Enable debug logs

Features

  • 🎯 Complete Coverage: Full support for tables, views, enums, functions and composite types
  • 🔧 Multi-Schema: Process multiple database schemas with a single command
  • 📦 Type Declarations: Generate corresponding .d.ts files alongside Zod schemas

Credits

This project started as a fork of supabase-to-zod by @psteinroe. While maintaining the original concept, the codebase has been completely rewritten to provide better performance, enhanced type safety, and a more robust architecture. Thanks to psteinroe for the initial inspiration! 💚

About

Generate Zod schemas from Supabase CLI generated types

Resources

License

Stars

Watchers

Forks

Packages

No packages published