Skip to content
100% local

SQL CREATE TABLE to Prisma schema

Convert SQL CREATE TABLE statements into Prisma schema models.

Input
Output

SQL CREATE TABLE to Prisma schema

Paste one or more SQL CREATE TABLE statements and this tool returns matching Prisma schema models — column types, primary keys, unique constraints and foreign-key relations included. It is built for developers migrating an existing PostgreSQL, MySQL or SQLite database into a Prisma project, or wiring up Prisma against a schema someone else designed in raw SQL.

Pick the source database so column types map correctly — a MySQL ENUM, a PostgreSQL UUID or a SQLite JSON column each need different handling, and the tool notes it inline when a type has no exact Prisma equivalent. Turn on singular PascalCase naming to get idiomatic model names (users becomes User) with an @@map back to the real table, and camelCase field names to get idiomatic Prisma fields (full_name becomes fullName) with an @map back to the real column — both are additive, so the underlying database schema never has to change. Foreign keys, whether declared inline, as a table-level constraint or via a separate ALTER TABLE statement, become proper Prisma relations on both sides, disambiguated with a named relation when more than one foreign key points at the same table.

Default values convert too: CURRENT_TIMESTAMP becomes @default(now()), AUTO_INCREMENT and SERIAL become @default(autoincrement()), and MySQL's ON UPDATE CURRENT_TIMESTAMP becomes @updatedAt. Nullable columns get a trailing question mark, composite keys become @@id, and composite or single-column unique constraints become @@unique or @unique depending on scope. Anything the converter can't represent exactly — an unsupported type, a CHECK constraint, an unsigned integer — is called out with a comment right above the affected field instead of being silently dropped or guessed at.

Everything runs locally in your browser: your schema is never uploaded anywhere, which matters if it describes a production database. Copy the result, download it as a .txt file to paste into schema.prisma, or send the output straight to another tool's input to keep refining it.

FAQ

Which source databases are supported?
PostgreSQL, MySQL and SQLite. Pick the right one in the options — it changes how types like UUID, JSON and unsigned integers are mapped, since Prisma supports different native types per provider.
How are foreign keys converted?
Inline column references, table-level FOREIGN KEY clauses and separate ALTER TABLE ... ADD FOREIGN KEY statements are all recognized and turned into a Prisma relation on both the referencing and the referenced model, with ON DELETE and ON UPDATE actions carried over.
What happens to a type with no Prisma equivalent?
It's mapped to the closest available type (usually String) and a comment is added above that field explaining the gap, so you know exactly what to review by hand.
Will the generated model names match my table names?
Only if you turn off singular PascalCase naming. Left on, a table like order_items becomes model OrderItem with an @@map("order_items") attribute, so Prisma still points at the real table.
Is my schema uploaded anywhere?
No. The conversion runs entirely in your browser — your SQL and the generated Prisma schema never leave your device.