SQL to Drizzle ORM Schema Generator
Generate Drizzle ORM table definitions from SQL DDL. Select your database dialect and get correctly typed pgTable, mysqlTable, or sqliteTable definitions with column types, constraints, and references.
SQL to TypeScript / Prisma / Drizzle Converter
Convert SQL CREATE TABLE statements into TypeScript interfaces, Prisma schema, or Drizzle ORM table definitions. Supports PostgreSQL, MySQL, and SQLite syntax.
SQL Type Mapping Reference
| SQL Type | TypeScript | Prisma |
|---|---|---|
| INT / INTEGER / SERIAL | number | Int |
| BIGINT / BIGSERIAL | number | BigInt |
| VARCHAR / TEXT / CHAR | string | String |
| BOOLEAN / BOOL | boolean | Boolean |
| TIMESTAMP / DATETIME | Date | DateTime |
| DECIMAL / NUMERIC | number | Decimal |
| JSON / JSONB | Record<string, unknown> | Json |
| UUID | string | String |
| BYTEA / BLOB | Buffer | Bytes |
How It Works
- SQL Parser -- parses CREATE TABLE statements supporting PostgreSQL, MySQL, and SQLite syntax including quoted identifiers, multi-word types, and constraints.
- TypeScript -- generates typed interfaces with SQL type mapping, nullable fields as
| nullor optional?. - Prisma -- generates Prisma models with @id, @default, @unique, @map, and @db.* annotations.
- Drizzle ORM -- generates table definitions using pgTable/mysqlTable/sqliteTable with correct column types and modifiers.
- Foreign keys -- detected from both inline REFERENCES and table-level FOREIGN KEY constraints.
- Everything runs in your browser -- no data is sent over the network.
What is Drizzle ORM?
Drizzle ORM is a lightweight, type-safe TypeScript ORM that provides a SQL-like query builder. Unlike Prisma, Drizzle schema definitions are written in TypeScript using helper functions like pgTable, mysqlTable, and sqliteTable. Each table is defined as a JavaScript object with column definitions that map directly to database columns.
How the converter generates Drizzle schemas
The converter maps SQL types to Drizzle column functions: integer(), varchar(), text(), boolean(), timestamp(), serial(), uuid(), json(), jsonb(), numeric(), real(), doublePrecision(), and more. Constraints are added as method chains: .primaryKey(), .notNull(), .unique(), .default(), and .references(). The output uses the correct import path based on your selected dialect (drizzle-orm/pg-core, drizzle-orm/mysql-core, or drizzle-orm/sqlite-core).
Drizzle vs Prisma schema
Drizzle schema is pure TypeScript code, making it easy to compose, generate, and version control alongside your application. Prisma uses its own DSL (.prisma files) that requires a separate code generation step. Drizzle provides a thinner abstraction over SQL, while Prisma offers a more opinionated data access layer. Choose based on your project's needs.
Frequently Asked Questions
Does the converter handle dialect-specific types?
Yes. The converter generates different column functions based on your selected dialect. PostgreSQL gets functions like uuid(), jsonb(), and timestamp with timezone support. MySQL gets int(), datetime(), and varchar with required length. SQLite maps everything to integer(), text(), real(), or blob().
Are foreign key references included?
Yes. Both inline REFERENCES and table-level FOREIGN KEY constraints are detected and converted to Drizzle .references(() => tableName.columnName) calls, maintaining referential integrity in your schema definition.
Related Convert Tools
JSON to Zod Converter
Convert JSON or JSON Schema to Zod validation schemas with $ref resolution, allOf/oneOf/anyOf, enum, format constraints, and required/optional fields
GraphQL to TypeScript
Convert GraphQL SDL schemas to TypeScript interfaces, types, enums, unions, and operations
TypeScript to JavaScript
Convert TypeScript to JavaScript — strip types, interfaces, enums, generics, and access modifiers to get clean JS output
JSON to SQL Converter
Convert JSON arrays to SQL CREATE TABLE and INSERT statements for PostgreSQL, MySQL, and SQLite with automatic type inference