Prisma Schema ↔ SQL DDL Converter

Convert between Prisma schema and MySQL/PostgreSQL DDL, including relations, enums, and indexes.

How to use the Prisma Schema ↔ SQL DDL Converter

  1. Pick your database in the SQL Dialect dropdown (MySQL or PostgreSQL) — this drives both directions.
  2. Paste a Prisma schema into the left panel to generate matching DDL on the right, or paste CREATE TABLE SQL into the right panel to generate a Prisma schema on the left.
  3. Both panels stay live and editable — keep typing in either one and the other updates automatically.
  4. Copy either panel's contents with its dedicated Copy button.

Relations, enums, and composite indexes/keys all round-trip: a foreign key and the primary key it references become a proper @relation pair (with the required back-relation field), and Prisma enums become native ENUM columns (MySQL) or CREATE TYPE ... AS ENUM types (PostgreSQL).

How This Tool Works

The converter parses whichever side you edit — a Prisma schema or SQL DDL — into a shared internal model of tables, columns, enums, indexes, and relations, then regenerates the other side from that model, so a `model` block with a `@relation` becomes a real `FOREIGN KEY` constraint (and vice versa), not just a text transformation.

Nothing you paste is ever sent to a server: parsing and generation both run entirely in your browser's JavaScript engine, using a small bundled SQL parser (node-sql-parser) plus a hand-written Prisma schema parser — nothing leaves your machine.

The SQL Dialect dropdown controls both directions at once: generating from Prisma always targets the selected dialect's syntax (backtick vs. double-quote identifiers, AUTO_INCREMENT vs. SERIAL, inline ENUM vs. CREATE TYPE), and parsing SQL always assumes the selected dialect's grammar — it isn't auto-detected, so pick MySQL or PostgreSQL to match your actual database before pasting.

Frequently Asked Questions

Advertisement

Related tools

Advertisement