What is SQL to Drizzle Schema Converter?
This tool converts SQL CREATE TABLE statements into Drizzle ORM TypeScript schema definitions. Drizzle ORM is a lightweight, type-safe ORM that provides SQL-like APIs for defining database schemas. The converter maps SQL data types to the appropriate Drizzle column builders for PostgreSQL, MySQL, or SQLite.
How to Use
- Select your database dialect (PostgreSQL, MySQL, or SQLite)
- Choose the import style: Table imports combines all imports, Inline separates them
- Paste your SQL CREATE TABLE statements into the input area
- Click "Generate Drizzle Schema" to create the TypeScript schema
- Copy the output and save it as a .ts file in your Drizzle ORM project
Why Use This Tool?
Tips & Best Practices
- Use PostgreSQL dialect for SERIAL columns — they map to serial().primaryKey()
- MySQL TINYINT(1) is automatically mapped to boolean() for MySQL dialect
- SQLite has fewer types — most types map to integer(), text(), real(), blob(), or numeric()
- REFERENCES constraints generate .references(() => tableVar.column) callbacks
- The Table imports style is recommended for cleaner import statements
Frequently Asked Questions
What is Drizzle ORM?
Drizzle ORM is a lightweight, type-safe TypeScript ORM for SQL databases. It provides a SQL-like API for defining schemas and querying data, with full TypeScript inference and zero runtime overhead.
How are SQL types mapped to Drizzle column builders?
SQL types are mapped to Drizzle column builders based on the selected dialect. For example, PostgreSQL SERIAL maps to serial(), VARCHAR(n) maps to varchar(n), BOOLEAN maps to boolean(). Each dialect has its own set of column builders from drizzle-orm/{pg,mysql,sqlite}-core.
Does it support all three Drizzle dialects?
Yes, the tool supports PostgreSQL (drizzle-orm/pg-core), MySQL (drizzle-orm/mysql-core), and SQLite (drizzle-orm/sqlite-core). Select the dialect that matches your database to get the correct column builder imports and type mappings.
Is my SQL data sent to a server?
No, all processing happens entirely in your browser. Your SQL schema never leaves your device. The conversion is performed client-side using a regex-based parser.