DB Diagram
April 9, 2026 ยท View on GitHub
Design, edit, and explore database schemas visually in VS Code.
๐ Features
๐ Diagram View
| Feature | Description |
|---|---|
| Live Connection | Connects directly to MySQL databases |
| Schema Visualization | Automatically renders all tables, columns, types, and PK/FK badges |
| 3 Layout Modes | ๐ Hierarchical, โ๏ธ Snowflake, ๐ฆ Compact |
| Drag & Drop | Move tables freely |
| Pan & Zoom | Pan with mouse, zoom with scroll (20%โ300%) |
| Fit to View | Fit all tables to the screen with a single click |
| PNG Export | Save the diagram as PNG |
โ๏ธ Editing
| Feature | Description |
|---|---|
| Add Table | Create new tables with a visual form |
| Add Column | Right-click โ Add Column (type, nullable, default, position) |
| Add Relationship | Visual FK builder โ select from/to table and column |
| Deletion | Delete Table / Column / FK via right-click menu |
| Raw SQL | Execute any DDL command |
๐ Search & Filtering
| Feature | Description |
|---|---|
| Table Search | Filter by table name |
| Column Search | Filter by column name or type |
| Type Filter | Filter by INT, VARCHAR, TEXT, JSON, etc. |
๐ Notes & History
| Feature | Description |
|---|---|
| Table Notes | Add notes to each table, view on hover |
| Snapshot History | Save and restore schema snapshots |
| Schema Diff | Compare differences between two snapshots |
๐ฆ Migration Export
| Format | Description |
|---|---|
| SQL | ALTER TABLE commands |
| Prisma | Prisma Schema |
| TypeORM | TypeORM Entities |
๐ Requirements
- VS Code 1.75+
- MySQL 5.7+ or MariaDB 10.3+
๐ Quick Start
1. Installation
cd db-diagram-designer
npm install
2. Compilation
npm run compile
# or watch mode:
npm run watch
3. Running
Press F5 in VS Code to open the Extension Development Host.
4. Connection
Open the Command Palette (Cmd+Shift+P) and run:
DB Diagram: Connect to Database
Enter your connection details (5 steps: host โ port โ user โ password โ database).
5. Opening the Diagram
The diagram opens automatically after connecting. Alternatively:
DB Diagram: Open Diagram
๐ Usage
Toolbar
| Button | Action |
|---|---|
๏ผ Table | Opens the table creation form |
โท Relation | Opens the FK relationship builder |
โ Query | Opens the Query Builder |
โจ SQL | Execute DDL commands |
๐ท | Export as PNG |
๐ฆ | Migration export |
๐ | Snapshot history |
โ | Schema Diff |
โก | Fit to view |
โป | Refresh schema |
Layout Modes
| Mode | Description |
|---|---|
| ๐ Hierarchical | Level-based arrangement based on FK relationships |
| โ๏ธ Snowflake | Most connected table in the center, others around it |
| ๐ฆ Compact | Tight grid layout, for tables with few relationships |
Canvas Interactions
| Interaction | Action |
|---|---|
| Drag table header | Move the table |
| Scroll | Zoom in/out |
| Drag empty space | Pan the canvas |
| Right-click โ table header | Table actions menu |
| Right-click โ column | Column deletion option |
| Right-click โ FK line | Relationship deletion option |
| Click table | Select (border highlighted) |
| Hover on ๐ icon | View note |
๐๏ธ Architecture
db-diagram-designer/
โโโ src/
โ โโโ extension.ts # Entry point, command registrations
โ โโโ db/
โ โ โโโ DatabaseManager.ts # Database connection manager
โ โ โโโ MySQLDatabase.ts # MySQL implementation
โ โ โโโ PostgreSQLDatabase.ts # PostgreSQL implementation
โ โ โโโ types.ts # Type definitions
โ โโโ panels/
โ โ โโโ ConnectionPanel.ts # Connection form webview
โ โ โโโ DiagramPanel.ts # Diagram webview panel
โ โโโ providers/
โ โ โโโ ConnectionsProvider.ts # Sidebar TreeView
โ โโโ managers/
โ โโโ SnapshotManager.ts # Snapshot management
โ โโโ SchemaDiffManager.ts # Schema comparison
โ โโโ MigrationManager.ts # Migration code generation
โโโ media/
โ โโโ diagram.html # Diagram webview HTML
โโโ package.json # Extension manifest
โโโ tsconfig.json
โก Performance
This extension includes performance optimizations:
- Lazy Loading: Renders only when needed
- Collision Avoidance: Tables are placed with automatic collision prevention
- Efficient Updates: Only changed parts are re-rendered
- Memory Management: Memory is cleared when webview is disposed
๐ Security
- Passwords are never saved โ only host/port/user/database are stored in
globalState - Webview uses CSP nonce โ inline scripts won't run without a nonce
- All SQL identifiers are protected with backticks
๐ License
MIT