← All tools
Free tool

SQL to Prisma schema converter

Turn PostgreSQL CREATE TABLE statements into a ready-to-use schema.prisma, models, native type mappings, ids, defaults, and relations on both sides.

schema.sql · 33 lines
schema.prisma · 5 models
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Users {
  id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  email String
  name String
  createdAt DateTime? @default(now()) @db.Timestamptz
  posts Posts[]
  comments Comments[]
}

model Posts {
  id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  userId String @db.Uuid
  title String
  body String?
  createdAt DateTime? @default(now()) @db.Timestamptz
  users Users @relation(fields: [userId], references: [id])
  comments Comments[]
  postTags PostTags[]
}

model Tags {
  id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  name String
  postTags PostTags[]
}

model Comments {
  id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  postId String @db.Uuid
  userId String @db.Uuid
  content String
  posts Posts @relation(fields: [postId], references: [id])
  users Users @relation(fields: [userId], references: [id])
}

model PostTags {
  postId String @id @db.Uuid
  tagId String @id @db.Uuid
  posts Posts @relation(fields: [postId], references: [id])
  tags Tags @relation(fields: [tagId], references: [id])
  @@map("post_tags")
}

Frequently asked questions

Is this the same as prisma db pull?

No, prisma db pull introspects a live database and needs credentials and a network round-trip. This tool converts SQL text you already have (a dump, a migration, docs) into schema.prisma syntax entirely in your browser. Use db pull for live databases; use this for SQL on your clipboard.

Is it free?

Yes, completely free with no signup. Paste DDL, copy schema.prisma, models, scalar types with native mappings, @id attributes, and @relation fields included.

Is my SQL uploaded anywhere?

No. Parsing and Prisma generation run entirely in your browser. Your schema is never uploaded, stored, or logged.

Which PostgreSQL features are supported?

Tables become models (PascalCase with @@map back to the table name), columns map to scalars with @db native types (Uuid, Timestamptz, Decimal), primary keys become @id, common defaults (gen_random_uuid(), now()) become @default, and foreign keys become @relation fields on both sides.

Can I turn the result into an ER diagram?

Yes. Click Visualize this schema to open the same SQL in dbdiagramr as an interactive ER diagram, the fastest way to review the relations Prisma will generate a client for.

Related tools

Turn it into an ER diagram

Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.