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.
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 : writesCREATE 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");⚡ Open the Converter
Try it now — no sign-up, no install
🔀 Schema Diff
Compare two diagram versions, see what changed
How It Works
The conversion pipeline has three stages:
- Parse — The diagram text is parsed into an intermediate Schema model (tables, columns, relationships, constraints).
- Normalize & Validate — Synthetic primary keys are added where missing, column names are deduplicated, and foreign-key targets are validated.
- 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
🧜 Mermaid ER
erDiagram syntax. Supports PK/FK/UK markers, %% directives for NOT NULL, DEFAULT, CHECK, CASCADE, composite indexes, enums, and more.
🌱 PlantUML
@startuml entity syntax. Supports * mandatory prefix, <<PK>> stereotypes, ' comment directives for advanced metadata.
Supported SQL Dialects
| Dialect | Auto-increment | Enums | Column comments | Table comments |
|---|---|---|---|---|
| PostgreSQL | SERIAL | CREATE TYPE … AS ENUM | COMMENT ON COLUMN | COMMENT ON TABLE |
| MySQL | AUTO_INCREMENT | Inline ENUM(…) | Inline COMMENT 'text' | Table option COMMENT='text' |
| SQLite | INTEGER PRIMARY KEY | Stored as TEXT with CHECK | — | — |
| Oracle 19c+ | GENERATED ALWAYS AS IDENTITY | Stored as VARCHAR2 with CHECK | COMMENT ON COLUMN | COMMENT ON TABLE |
Supported ORM Frameworks
| Framework | Language | Tier |
|---|---|---|
| GORM | Go | Free |
| SQLAlchemy | Python | Developer+ |
| TypeORM | TypeScript | Developer+ |
| Prisma | TypeScript | Developer+ |
| JPA / Hibernate | Java | Developer+ |
| Django ORM | Python | Developer+ |
| Sequelize | JavaScript | Developer+ |
| Entity Framework Core | C# | Developer+ |
Navigation
Use the sidebar on the left (or the menu above on mobile) to navigate the documentation sections:
- Mermaid ER Syntax — full syntax reference including
%%directives - PlantUML Syntax — entity syntax, stereotypes, and
'directives - SQL DDL Generation — type mapping, constraints, dialect differences
- ORM Generation — per-framework examples and field mapping
- Schema Diff — comparing two diagram versions
- API Reference — REST endpoints, request/response shapes, authentication