Skip to main content

SQL to Prisma Schema

New

Convert CREATE TABLE SQL statements into Prisma schema models.

sqlprismaormschemaconvert
Read the guide
Shortcuts:⌘ KSearch

Convert CREATE TABLE to a Prisma model

Paste one or more CREATE TABLE statements (standard SQL, MySQL, or PostgreSQL) and get equivalent Prisma schema models, including primary keys, nullability, defaults, and @unique/@id attributes.

Continue with:

Frequently Asked Questions

How are column names converted to Prisma field names?

Snake_case columns are converted to camelCase for the Prisma field name, and if that changes the name, a @map("original_column") attribute is added so Prisma still points at the real database column.

How is the primary key detected?

It recognizes both inline PRIMARY KEY on a column definition and a separate PRIMARY KEY (col1, col2) constraint line, marking the matching field(s) with @id.

Does AUTO_INCREMENT or SERIAL map to anything in Prisma?

Yes — both map to @default(autoincrement()), which is the Prisma equivalent for auto-incrementing integer primary keys.

Can I paste multiple CREATE TABLE statements at once?

Yes. The input is split into one model per CREATE TABLE statement it finds, and all resulting models are printed one after another in the output.

What happens to foreign keys and indexes?

FOREIGN KEY, KEY, and INDEX constraint lines are currently skipped — Prisma relations need corresponding fields on both related models, which this heuristic single-table parser can't infer safely, so you'll need to add @relation fields manually.

Related Tools