Documentation

Diagram2Code converts Mermaid ER diagrams and PlantUML entity-relationship diagrams into production-ready SQL DDL and ORM model code. This documentation covers everything from a 2-minute quick start to the full API reference.

Quick Start

No account required. Paste your diagram, select a target, and click Convert.

Input — Mermaid ER diagram
erDiagram
    USER {
        int id PK
        string email UK
        string name
    }
    POST {
        int id PK
        int user_id FK
        string title
        text body
    }
    USER ||--o{ POST : writes
Output — PostgreSQL DDL
CREATE TABLE "user" (
    "id"    SERIAL PRIMARY KEY,
    "email" TEXT UNIQUE,
    "name"  TEXT
);

CREATE TABLE "post" (
    "id"      SERIAL PRIMARY KEY,
    "user_id" INTEGER,
    "title"   TEXT,
    "body"    TEXT
);

ALTER TABLE "post"
    ADD CONSTRAINT "fk_post_user_id"
    FOREIGN KEY ("user_id")
    REFERENCES "user"("id");

How It Works

The conversion pipeline has three stages:

  1. Parse — The diagram text is parsed into an intermediate Schema model (tables, columns, relationships, constraints).
  2. Normalize & Validate — Synthetic primary keys are added where missing, column names are deduplicated, and foreign-key targets are validated.
  3. Generate — The Schema model is rendered into dialect-specific SQL or framework-specific ORM code using type mapping tables and configurable templates.

Because all parsers produce the same intermediate Schema, a Mermaid diagram and a PlantUML diagram with identical structure will produce identical SQL output.

Supported Input Formats

Supported SQL Dialects

DialectAuto-incrementEnumsColumn commentsTable comments
PostgreSQLSERIALCREATE TYPE … AS ENUMCOMMENT ON COLUMNCOMMENT ON TABLE
MySQLAUTO_INCREMENTInline ENUM(…)Inline COMMENT 'text'Table option COMMENT='text'
SQLiteINTEGER PRIMARY KEYStored as TEXT with CHECK
Oracle 19c+GENERATED ALWAYS AS IDENTITYStored as VARCHAR2 with CHECKCOMMENT ON COLUMNCOMMENT ON TABLE

Supported ORM Frameworks

FrameworkLanguageTier
GORMGoFree
SQLAlchemyPythonDeveloper+
TypeORMTypeScriptDeveloper+
PrismaTypeScriptDeveloper+
JPA / HibernateJavaDeveloper+
Django ORMPythonDeveloper+
SequelizeJavaScriptDeveloper+
Entity Framework CoreC#Developer+

Navigation

Use the sidebar on the left (or the menu above on mobile) to navigate the documentation sections: