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

SQL to Prisma Schema Generator

Generate Prisma schema models directly from your SQL DDL. This tool parses CREATE TABLE statements and produces Prisma models with correct types, decorators, and field mappings.

← 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 Prisma Schema?

Prisma schema is the central configuration file for Prisma ORM. It defines your data models, their fields, types, and relationships using a declarative syntax. Each model maps to a database table, and Prisma uses the schema to generate a type-safe query client for TypeScript and JavaScript applications.

How the converter maps SQL to Prisma

The converter maps SQL column types to Prisma scalar types: INT becomes Int, VARCHAR becomes String, BOOLEAN becomes Boolean, TIMESTAMP becomes DateTime, DECIMAL becomes Decimal, and JSON/JSONB becomes Json. Constraints like PRIMARY KEY map to @id, UNIQUE to @unique, DEFAULT to @default, and AUTO_INCREMENT to @default(autoincrement()). Column names are converted to camelCase with @map annotations preserving the original SQL name.

Prisma annotations generated

The tool generates @id for primary keys, @unique for unique constraints, @default(autoincrement()) for serial/auto-increment columns, @default(now()) for timestamp defaults, @default(uuid()) for UUID generation, @map for column name mapping, @db.* annotations for database-specific types (e.g., @db.VarChar(255), @db.Uuid, @db.Timestamptz), and @@index/@@unique for table-level indexes.

Frequently Asked Questions

Does this tool handle foreign key relationships?

The tool detects REFERENCES and FOREIGN KEY constraints and annotates columns accordingly. For full Prisma relation fields, you may need to add relation annotations manually since Prisma relations require both sides of the relationship to be defined.

Which SQL dialects are supported?

The parser handles PostgreSQL, MySQL, and SQLite CREATE TABLE syntax including quoted identifiers (backticks and double quotes), multi-word types like TIMESTAMP WITH TIME ZONE, and dialect-specific features like SERIAL, AUTO_INCREMENT, and AUTOINCREMENT.

Related Convert Tools