What is SQL to Prisma Schema Converter?
This tool converts SQL CREATE TABLE statements into Prisma ORM schema definitions. Prisma is a next-generation ORM for Node.js and TypeScript that provides type-safe database access. The converter maps SQL data types to Prisma scalar types and generates complete schema files with models, relations, and annotations.
How to Use
- Select your database dialect (PostgreSQL, MySQL, SQLite, or SQL Server)
- Paste your SQL CREATE TABLE statements into the input area
- Click "Generate Prisma Schema" to create the schema.prisma content
- Copy the output and save it as schema.prisma in your Prisma project
Why Use This Tool?
Tips & Best Practices
- SERIAL columns are automatically mapped to @id(default: autoincrement())
- Foreign key REFERENCES generate @relation annotations
- Model names are converted to PascalCase, table names preserved with @@map
- JSONB/JSON columns map to the Json type for flexible data structures
- UUID columns map to String type with proper handling
Frequently Asked Questions
What is Prisma Schema?
Prisma Schema is a declarative configuration language used by Prisma ORM to define database models, relations, and datasource settings. It serves as the single source of truth for your database structure and is used to generate type-safe Prisma Client.
How are SQL types mapped to Prisma types?
SQL types are mapped to Prisma scalar types based on the selected dialect. For example, VARCHAR → String, INTEGER → Int, BOOLEAN → Boolean, TIMESTAMP → DateTime, JSONB → Json, DECIMAL → Decimal, UUID → String.
Does it support all four database providers?
Yes, the tool supports PostgreSQL, MySQL, SQLite, and SQL Server. Each provider has its own type mappings and the generated schema uses the correct provider value in the datasource block.
How are foreign keys handled?
REFERENCES constraints generate @relation annotations in Prisma. For example, user_id INTEGER REFERENCES users(id) becomes userId Int @relation(fields: [userId], references: [id]) with a corresponding user User relation field.
Is my SQL data sent to a server?
No, all processing happens entirely in your browser. Your SQL schema never leaves your device. The conversion is performed client-side using a regex-based parser.