SQL to Prisma Schema Converter
Paste any CREATE TABLE statement and get a production-ready Prisma schema with models, relations, enums, and indexes — no database connection required.
Runs 100% in your browser. Your input and files never leave your device.
Why use our online SQL to Prisma Schema Converter?
Converting a CREATE TABLE statement to a Prisma schema by hand means carefully mapping every SQL type to its Prisma equivalent and @db attribute, re-writing foreign keys as @relation fields, and translating CHECK constraints and partial indexes to comments. This tool does that work deterministically in your browser.
How to use SQL to Prisma Schema Converter
- 1Paste your SQL
Paste one or more CREATE TABLE statements. The Prisma tab is pre-selected.
- 2Review the output
The right panel shows a complete schema.prisma with datasource, generator, enums, and models.
- 3Check the type mapping
Expand the Type Mapping panel to verify every column — SQL type → Prisma field type + @db attribute.
- 4Copy or download
Click Copy to grab schema.prisma, or Download ZIP for the full output.
Frequently Asked Questions
How are PostgreSQL-specific types like TIMESTAMPTZ and JSONB handled in Prisma?
TIMESTAMPTZ maps to DateTime @db.Timestamptz(6), JSONB maps to Json, UUID maps to String @db.Uuid, and BYTEA maps to Bytes. The @db decorator ensures the underlying PostgreSQL column type is preserved even though the Prisma field type is more generic.
How are foreign keys rendered in Prisma output?
Each foreign key becomes an @relation field on the owning side. The converter infers the relation name from the FK column name (e.g. author_id → author field with @relation(fields: [authorId], references: [id])). ON DELETE CASCADE and other actions are preserved.
What Prisma version is the output targeting?
Prisma 5.x. The output uses the @db attribute syntax introduced in Prisma 2.x and stable in 5.x. If you are on Prisma 4, the output is compatible — just verify the datasource provider field.
Are composite primary keys supported?
Yes. A table with PRIMARY KEY (col1, col2) generates @@id([col1, col2]) in the Prisma model.
Why does my partial index show as a comment in the output?
Prisma does not support partial indexes in the schema DSL. The converter emits a @@index comment with the WHERE clause so you can recreate it in a raw migration using prisma.$executeRaw or a migration SQL file.
Related Tools
More Developer Tools- JSON FormatterClean, minify, and validate JSON data structures.Free • In browser
- SQL FormatterFormat, beautify, and minify SQL queries online. Supports MySQL, PostgreSQL, SQLite, and more SQL dialects.Free • In browser
- Regex TesterReal-time expression matching and testing.Free • In browser
Also useful: Cron BuilderMermaid Live Editor