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 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.
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
ZOD
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
GQL
GraphQL to TypeScript
Convert GraphQL SDL schemas to TypeScript interfaces, types, enums, unions, and operations
TS
TypeScript to JavaScript
Convert TypeScript to JavaScript — strip types, interfaces, enums, generics, and access modifiers to get clean JS output
SQL
JSON to SQL Converter
Convert JSON arrays to SQL CREATE TABLE and INSERT statements for PostgreSQL, MySQL, and SQLite with automatic type inference