Skip to main content

Drizzle Schema Generator

Define your table name and columns to generate a Drizzle ORM pgTable schema for PostgreSQL. Choose column types, set nullable/primary key flags, and add defaults. Outputs both the table definition and the inferred TypeScript type. Runs entirely in your browser — nothing is sent to a server.

✓ drizzle-orm/pg-core output ✓ $inferSelect TypeScript type ✓ Nullable, PK, and default support ✓ Runs 100% in your browser
Columns
Generated Schema

Drizzle Column Type Reference

Type Drizzle Helper TypeScript Type
texttext('col')string
varcharvarchar('col', { length: 255 })string
integerinteger('col')number
bigintbigint('col', { mode: 'number' })number
booleanboolean('col')boolean
timestamptimestamp('col')Date
jsonjson('col')unknown
uuiduuid('col')string
serialserial('col')number

Frequently Asked Questions

What is Drizzle ORM and why use it?▼

Drizzle ORM is a TypeScript-first ORM for Node.js that gives you SQL-like syntax in TypeScript. Unlike Prisma, Drizzle generates no runtime client — it compiles your schema to raw SQL queries at build time. This means zero magic, full type safety, and excellent performance. It supports PostgreSQL, MySQL, and SQLite with a unified API.

What does pgTable do in Drizzle?▼

pgTable() is the core function for defining a PostgreSQL table in Drizzle ORM. You pass the table name as the first argument and a column definition object as the second. Each column is typed using helpers like text(), integer(), boolean(), timestamp(), etc. from drizzle-orm/pg-core. The result is a typed table object you use in queries.

What is $inferSelect and when do I use it?▼

$inferSelect is a TypeScript utility type provided by Drizzle that infers the TypeScript type of a row returned from a SELECT query on your table. Use it to type function parameters, API responses, or state variables without manually writing an interface. There is also $inferInsert for insert row types (which respects optional/default columns).

How do I use the generated schema in my project?▼

Copy the generated schema into a file like schema.ts in your project. Import drizzle-orm/pg-core at the top. Then import your table in query files and use it with a Drizzle db instance: db.select().from(yourTable). Drizzle reads the column types and builds fully typed SQL — autocomplete works in VSCode and TypeScript will catch type mismatches at compile time.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Terraform Resource Generator Prisma Schema Visualizer Terraform Variable Builder Code Tools Terraform Variable Validator JSON Schema Form Builder SQL Query Formatter Pro JSON Schema to Zod Converter SQL to TypeScript Types LLM JSON Schema Builder Database Schema Diff Neon DB Query Builder Turso Edge DB Explorer JSON Schema Generator JSON-LD Schema Generator Zod Schema Generator Terraform tfvars Generator Prisma Schema Builder Terraform Variable Generator TypeScript Discriminated Union Builder Web Performance Checklist JavaScript Formatter & Minifier Number Formatter SQL Formatter & Beautifier TypeScript Playground TypeScript to JavaScript Converter SQL ERD Diagram Generator TypeScript tsconfig.json Generator Database Schema Visualizer OpenAI Function Calling Generator PostgreSQL Connection String Builder PlanetScale Branch Manager JSON to TypeScript Interface Prettier Config Generator XML Formatter & Validator SQL Index Advisor PostgreSQL EXPLAIN Analyzer SQL Query Formatter Terraform State Inspector Database Index Analyzer YAML Validator Pro GraphQL Query Formatter Lighthouse Score Simulator AWS CDK Infrastructure as Code Guide Pulumi Modern IaC Guide XML Prettifier Database Index Advisor Pulumi Stack Config Generator Web Vitals Budget Planner Zustand Store Builder GraphQL Client Configurator Axios Interceptor Builder Jest Mock Generator Core Web Vitals Guide API Response Formatter & Analyzer Color Format Converter CSS Formatter & Minifier CSV Editor ESLint Config Generator Git Commit Message Generator HTML Formatter & Minifier JSON Formatter Pro JSON Formatter & Validator Markdown Table Generator Resume Bullet Generator UUID Generator UUID v7 Generator YAML Validator & Formatter WebP Converter Web Vitals Scorer Biome Config Generator GraphQL Query Builder GCP Service Account Key Checker Grafana Dashboard JSON Validator HAR Diff Analyzer MySQL Query Explainer OpenAPI Schema Validator GraphQL Fragment Generator Vitest Configuration Generator k6 Load Test Script Generator HTTP/2 Server Push Headers Builder Kafka Topic Config Generator Jest Coverage Config Generator Web Vitals Analyzer GraphQL Schema Validator v2 YAML to JSON Converter Storybook Component Development Guide Core Web Vitals Calculator Image Compression Estimator Sitemap.xml Validator CSV JSON Transformer OpenAPI Mock Generator Playwright Test Generator AI Agent Memory Planner RAG Chunking Calculator MCP Endpoint Tester Solana Program ID Generator Multi-Chain Wallet Address Validator ZITADEL Color Format Converter — HEX, RGB, HSL, HSV GitHub Actions Matrix Builder WebAssembly Binary Inspector LLM Benchmark Calculator k6 Script Generator TanStack Query Config Builder SWR Config Generator Jotai Atom Explorer RAG Chunking Calculator Core Web Vitals Budget Calculator Bundle Size Budget Calculator Image Optimization Calculator TTFB Analyzer Embedding Storage Calculator RAG Chunk Size Optimizer Database Query Cost Analyzer React Component Generator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →