SQL → ORM
Convert SQL DDL to Prisma or Drizzle schema definitions instantly.
Runs entirely in your browser. No server calls.
How to use SQL → ORM
Paste your SQL DDL
Drop a CREATE TABLE statement into the editor, or load one of the samples.
Configure and convert
Pick ORM, dialect, and options. Click Convert or press ⌘↵.
Copy the schema
Copy the Prisma or Drizzle schema to your project.
Frequently asked questions
Is this free?↓
Yes, completely free. No sign-up, no rate limits.
Does my code get sent to a server?↓
No. All conversion runs entirely in your browser. Nothing is sent to any server.
Are all SQL column types mapped?↓
Common types (INT, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, etc.) are mapped. Exotic vendor-specific types fall back to String / text.
Are foreign keys handled?↓
Yes — foreign keys detected from REFERENCES become @relation / references() directives in the output schema.
Try other tools
View allLong-form guide
Convert SQL DDL into Prisma or Drizzle schema, with relations intact
SQL → ORM turns your SQL CREATE TABLE statements into a Prisma schema or Drizzle table definitions, with relations, indexes, and dialect-specific types all preserved. Paste DDL on the left, pick your ORM, set a couple of toggles, and the generated schema appears on the right — copy it, drop it into your project, and you're shipping.
How to use it
- Paste your DDL. Drop one CREATE TABLE statement or your whole schema. The parser handles standard PostgreSQL, MySQL, and SQLite syntax. Use the Sample selector to load a typical blog schema if you want a reference shape before pasting your own.
- Pick your ORM. Prisma generates a schema.prisma with models, types, and relations. Drizzle generates a TypeScript file with table definitions, ready to import. Both produce idiomatic output you'd have written by hand.
- Pick the DB dialect. Postgres, MySQL, or SQLite. For Drizzle this affects which column helpers get imported (pg, mysql2, better-sqlite3). For Prisma it sets the datasource provider in the schema header.
- Toggle options. Indexes preserves CREATE INDEX statements as @@index in Prisma or index() calls in Drizzle. Foreign keys and Include relations turn REFERENCES into typed relations. Timestamps adds createdAt/updatedAt to every model. Soft delete adds a nullable deletedAt.
- Click Convert (or press ⌘↵). Output appears on the right. Copy with the corner button or download as
schema.prismaorschema.tsdirectly.
What the converter handles
Tables become models (Prisma) or pgTable / mysqlTable / sqliteTable calls (Drizzle). Column types map cleanly: INT, BIGINT, SMALLINT, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, DATE, TIME, DECIMAL, JSON, JSONB, UUID. Lengths on VARCHAR and DECIMAL are preserved. NOT NULL becomes required; absence becomes optional (? in Prisma, no .notNull() in Drizzle).
Constraints translate too. PRIMARY KEY becomes @id in Prisma or .primaryKey() in Drizzle. UNIQUE becomes @unique or .unique(). CHECK constraints are preserved as comments — neither ORM exposes them as first-class — and DEFAULT values become @default(...) or .default(...) calls. Composite primary keys use @@id or composite primaryKey() definitions.
Foreign keys become typed relations. REFERENCES users(id) becomes @relation in Prisma or references(() => users.id) in Drizzle. The reverse side of the relation is added on the parent table for Prisma; in Drizzle it's left as a one-directional reference (Drizzle's idiomatic style). Cascade behaviors (ON DELETE CASCADE, ON UPDATE) are preserved.
Indexes from CREATE INDEX statements are picked up and emitted as @@index([columns]) (Prisma) or index().on(table.column) (Drizzle). Composite indexes work; partial indexes (with WHERE clauses) are emitted with a comment since neither ORM has first-class syntax for them yet.
When to reach for it
Migrating a legacy Postgres or MySQL database to a Node.js stack is the obvious case. Dump your DDL with pg_dump --schema-only, paste it in, get a working Prisma or Drizzle schema in seconds. Adopting an ORM in an existing project is similar: introspect your database to SQL, convert here, drop into the codebase.
It's also a learning tool. Paste a SQL schema you don't fully understand and see how it expresses in Prisma's relational metaphors or Drizzle's table builder. Switching ORMs mid-project also gets easier — convert SQL to the new ORM directly without retyping every column.
SQL → ORM превращает SQL CREATE TABLE в Prisma-схему или Drizzle-определения таблиц с сохранёнными relations, индексами и типами под диалект. Вставил DDL слева, выбрал ORM, выставил пару переключателей — справа появляется готовая схема, копируй и подключай.
Как использовать
- Вставь DDL. Один CREATE TABLE или всю схему. Парсер понимает стандартный PostgreSQL, MySQL и SQLite синтаксис. В Sample есть типичная блог-схема для референса.
- Выбери ORM. Prisma даёт schema.prisma с моделями, типами и relations. Drizzle даёт TypeScript-файл с определениями таблиц, готовый к импорту. Оба производят идиоматичный код, который ты написал бы руками.
- Выбери диалект. Postgres, MySQL или SQLite. Для Drizzle это влияет на импорт хелперов (pg, mysql2, better-sqlite3). Для Prisma — устанавливает datasource provider в шапке схемы.
- Переключатели. Indexes сохраняет CREATE INDEX как @@index в Prisma или вызовы index() в Drizzle. Foreign keys и Include relations превращают REFERENCES в типизированные связи. Timestamps добавляет createdAt/updatedAt в каждую модель. Soft delete — nullable deletedAt.
- Нажми Convert (или ⌘↵). Результат справа. Скопируй кнопкой в углу или скачай как
schema.prismaилиschema.ts.
Что обрабатывает конвертер
Таблицы становятся моделями (Prisma) или вызовами pgTable / mysqlTable / sqliteTable (Drizzle). Типы колонок маппятся чисто: INT, BIGINT, SMALLINT, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, DATE, TIME, DECIMAL, JSON, JSONB, UUID. Длины VARCHAR и DECIMAL сохраняются. NOT NULL становится обязательным; отсутствие — опциональным (? в Prisma, без .notNull() в Drizzle).
Constraints тоже транслируются. PRIMARY KEY → @id в Prisma или .primaryKey() в Drizzle. UNIQUE → @unique или .unique(). CHECK сохраняются как комментарии — ни одна ORM не делает их first-class — а DEFAULT-значения становятся @default(...) или .default(...). Составные первичные ключи используют @@id или композитные определения primaryKey().
Foreign keys становятся типизированными relations. REFERENCES users(id) → @relation в Prisma или references(() => users.id) в Drizzle. Обратная сторона связи добавляется на родительскую таблицу для Prisma; в Drizzle оставляется одна сторона (идиоматичный стиль). Каскадные поведения (ON DELETE CASCADE, ON UPDATE) сохраняются.
Индексы из CREATE INDEX подхватываются и выводятся как @@index([columns]) (Prisma) или index().on(table.column) (Drizzle). Составные работают; частичные (с WHERE) выводятся с комментарием, потому что ни одна ORM пока не имеет first-class синтаксиса.
Когда это пригодится
Миграция legacy Postgres или MySQL в Node.js-стек — очевидный случай. Сдампил DDL через pg_dump --schema-only, вставил, получил рабочую Prisma- или Drizzle-схему за секунды. Адаптация ORM в существующем проекте — то же самое: интроспекция БД в SQL, конвертация здесь, вставка в кодбейз.
Это ещё и обучающий инструмент. Вставил SQL-схему, которую не до конца понимаешь, увидел, как она выражается в реляционных метафорах Prisma или table builder Drizzle. Смена ORM посреди проекта тоже становится проще — конвертировал SQL в новую ORM напрямую, без перепечатывания каждой колонки.
Examples
CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, name VARCHAR(100), created_at TIMESTAMP DEFAULT NOW() );
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
createdAt DateTime @default(now())
}CREATE TABLE posts ( id SERIAL PRIMARY KEY, user_id INT NOT NULL REFERENCES users(id), title VARCHAR(255) NOT NULL, body TEXT );
import { pgTable, serial, integer, varchar, text } from 'drizzle-orm/pg-core';
import { users } from './users';
export const posts = pgTable('posts', {
id: serial('id').primaryKey(),
userId: integer('user_id').references(() => users.id).notNull(),
title: varchar('title', { length: 255 }).notNull(),
body: text('body'),
});CREATE TABLE follows ( follower_id INT NOT NULL, following_id INT NOT NULL, PRIMARY KEY (follower_id, following_id) ); CREATE INDEX follows_following_idx ON follows(following_id);
model Follow {
followerId Int
followingId Int
@@id([followerId, followingId])
@@index([followingId])
}