Prisma Schema from SQL

Paste your SQL CREATE TABLE / ALTER TABLE DDL and get a ready-to-use schema.prisma — models, fields with types and defaults, @id/@unique/@@index attributes, and @relation fields inferred from foreign keys. PostgreSQL, MySQL, SQLite and SQL Server. Nothing is executed; it runs entirely in your browser.

Try:
schema.prisma

About this tool

Prisma Schema from SQL turns raw SQL DDL into a schema.prisma you can drop straight into a Prisma project. Paste one or more CREATE TABLE statements (plus any ALTER TABLE ... ADD and CREATE INDEX lines) and it produces a model for each table with:

It supports PostgreSQL, MySQL, SQLite and SQL Server, and it's a lenient parser, not a database: comments and non-DDL statements (INSERT, SELECT, DROP, …) are ignored and nothing is ever executed. Everything runs locally in your browser — your schema never leaves the page.

Worked example

Given this PostgreSQL DDL:

CREATE TABLE users (id SERIAL PRIMARY KEY);
CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  total DECIMAL(10,2) NOT NULL
);

you get:

model users {
  id Int @id @default(autoincrement())
}

model orders {
  id Int @id @default(autoincrement())
  user_id Int
  total Decimal @db.Decimal(10, 2)
  user users @relation(fields: [user_id], references: [id], onDelete: Cascade)
}

Turn Map names to Prisma conventions on and the models become User/Order with camelCase fields and @@map/@map back to the original database names.

FAQ

Does this connect to my database or run my SQL?

No. It only reads the DDL text you paste — CREATE TABLE, ALTER TABLE ... ADD and CREATE INDEX. It never opens a connection and never executes anything. INSERT, SELECT, DROP and comments are skipped, and the whole conversion happens in your browser, so nothing is uploaded.

How are foreign keys turned into relations?

Each foreign key becomes a Prisma @relation field on the owning model, with fields: [...] (the local columns) and references: [...] (the referenced columns), plus onDelete/onUpdate actions mapped to Prisma's Cascade, Restrict, SetNull, SetDefault or NoAction. A user_id column referencing users produces a user field; when two foreign keys point at the same table, each gets an explicit relation name so Prisma can tell them apart. Prisma also expects the back-relation on the other model — add those opposite fields (e.g. orders Order[]) yourself, or let prisma format prompt for them.

Why does a column come out as String or dbgenerated(...)?

String is Prisma's fallback for any textual or unrecognized type, so an exotic or vendor-specific type you didn't expect will land there — change it by hand if needed. @default(dbgenerated("…")) is used when a column default is an expression the tool can't reduce to a Prisma helper (now(), uuid(), a literal), which keeps the exact SQL default without guessing at its meaning.

What does "Map names to Prisma conventions" do?

Off (the default), table and column names are used verbatim — only sanitized to valid Prisma identifiers. On, model names become PascalCase and singularized (blog_postsBlogPost) and fields become camelCase (full_titlefullTitle), while @@map/@map preserve the original database names so the schema still points at your real tables and columns.

Which providers are supported, and does the provider matter?

PostgreSQL, MySQL, SQLite and SQL Server. The provider sets the datasource block, tunes parsing (for example MySQL's TINYINT(1) becomes Boolean), and decides which native @db.* types are valid — SQLite has none, so native types are omitted there even when the toggle is on.

Limits

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool prisma-schema-from-sql "CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE,
  created_at TIMESTAMP DEFAULT now()
);"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/prisma-schema-from-sql/?input=CREATE%20TABLE%20users%20%28%0A%20%20id%20SERIAL%20PRIMARY%20KEY%2C%0A%20%20email%20VARCHAR%28255%29%20NOT%20NULL%20UNIQUE%2C%0A%20%20created_at%20TIMESTAMP%20DEFAULT%20now%28%29%0A%29%3B&provider=postgresql&header=true&relations=true&native_types=true&map_names=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.