DevBolt
Processed in your browser. Your data never leaves your device.

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.

← Back to tools

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 TypeTypeScriptPrisma
INT / INTEGER / SERIALnumberInt
BIGINT / BIGSERIALnumberBigInt
VARCHAR / TEXT / CHARstringString
BOOLEAN / BOOLbooleanBoolean
TIMESTAMP / DATETIMEDateDateTime
DECIMAL / NUMERICnumberDecimal
JSON / JSONBRecord<string, unknown>Json
UUIDstringString
BYTEA / BLOBBufferBytes

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 | null or 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