SQL DDL to Prisma Converter
A tool that parses SQL CREATE TABLE statements (DDL) and converts them into schema.prisma model definitions. It supports common PostgreSQL, MySQL, and SQLite types, primary keys, unique constraints, indexes, relations from foreign keys, and ENUM types — all processed in your browser.
How to use
- Paste CREATE TABLE statements on the left, or load a .sql file (such as pg_dump or mysqldump output) with "Open file" or by drag and drop.
- Under "Conversion options", choose the database type, whether to apply Prisma naming conventions, whether to output native type attributes, and whether to include generator and datasource blocks.
- The schema.prisma model definitions appear on the right. Relation fields and their back-relations are generated automatically from foreign keys.
- If warnings appear, review them, then save with "Copy to clipboard" or "Download schema.prisma".
About this tool
When adopting Prisma for an existing database, you'd normally connect to it with prisma db pull to import the schema. But sometimes you only have a DDL file, can't connect to the production database, or want to create models from table definitions still in design. This tool builds schema.prisma model definitions from CREATE TABLE statements alone.
Column types are mapped to Prisma types (String, Int, BigInt, Decimal, DateTime, Json, and so on), and length constraints like VARCHAR(255) are kept as @db.VarChar(255). PRIMARY KEY becomes @id / @@id, UNIQUE becomes @unique / @@unique, CREATE INDEX becomes @@index, SERIAL and AUTO_INCREMENT become @default(autoincrement()), and DEFAULT now() becomes @default(now()). Foreign keys produce relations between the related models, including ON DELETE behavior.
SQL is parsed by a custom parser in your browser, and your table definitions are never sent to a server. Statements other than CREATE TABLE — such as views, triggers, and functions — are skipped. We recommend checking the result with prisma validate or prisma format before using it.
Frequently asked questions
Which databases' DDL is supported?
Common CREATE TABLE syntax for PostgreSQL, MySQL (MariaDB), and SQLite is supported. Primary keys and foreign keys added later via ALTER TABLE, as in pg_dump output, are also applied.
What happens to types that can't be converted?
Types with no Prisma equivalent, such as PostGIS geometry, are output as Unsupported("type") with a warning. Note that Prisma Client can't read or write Unsupported columns.
How are relation field names chosen?
The foreign key column name without "_id" is used (author_id → author). When two tables have multiple relations between them, or a table references itself, the relations are given names via @relation to tell them apart.
Is my SQL sent to a server?
No. Parsing the SQL and generating schema.prisma both happen in your browser.