DevBolt
Processed in your browser. Your data never leaves your device.
← 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.

Frequently Asked Questions

How do I convert SQL CREATE TABLE to TypeScript interfaces?
Paste SQL CREATE TABLE statements into the converter. It parses column names, data types, nullability, and defaults to generate TypeScript interfaces. SQL types map to TypeScript: VARCHAR/TEXT become string, INTEGER/BIGINT become number, BOOLEAN becomes boolean, TIMESTAMP/DATE become Date or string, and NUMERIC/DECIMAL become number or string for precision. NOT NULL columns are required, nullable columns get optional or null union types. DevBolt generates one interface per table with proper PascalCase naming.
What is the difference between Prisma schema and Drizzle ORM output?
Prisma uses its own declarative schema language with models, field types, and attributes like @id, @default, @unique. It generates a type-safe client with findMany, create, and update methods. Drizzle uses plain TypeScript with functions like pgTable, varchar, integer, exporting table objects. Drizzle supports raw SQL more naturally. The converter outputs either Prisma's .prisma format or Drizzle's TypeScript definitions with your chosen database dialect. Foreign keys are preserved in both formats.
How are SQL foreign keys converted to TypeScript or ORM schemas?
For TypeScript interfaces, foreign key columns become number or string properties with JSDoc comments noting the relationship. For Prisma, relationships become @relation attributes connecting the foreign key to the referenced model. For Drizzle, relationships use the relations() helper with one() and many() definitions. Primary keys, unique constraints, and indexes are preserved as corresponding decorators or method calls.

Related Convert Tools