Your schema, in focus. Instant ERD from the files you already write.
Schema Lens parses your SQL migrations, Prisma schemas, Drizzle schemas, and Knex migrations and renders an interactive ERD directly inside VS Code, with no database connection required.
-
Interactive ERD in VS Code
Entity-relationship diagrams with zoom and pan in a side panel next to your editor. -
File-first, multi-format support
Works from the files you already maintain:- Raw SQL (
.sql) - Prisma (
schema.prisma) - Drizzle ORM schema files (
pgTable,mysqlTable,sqliteTable) - Knex.js migration files (
createTableetc.)
- Raw SQL (
-
Live reload on save
Edit your migration or schema, hit save, and the diagram refreshes automatically. -
Visual diff mode
Compare two schema files and see:- 🟢 Added tables and columns
- 🔴 Removed tables and columns
- 🟡 Modified tables
-
Respects your theme
Diagram styling follows your VS Code light or dark theme preferences.
- Download the
.vsixfile from the Releases page. - In VS Code, open the Extensions view, open the “Views and More Actions…” menu (
…), and choose Install from VSIX…. [web:135] - Select the downloaded
.vsixfile and complete the install.
- Open VS Code.
- Go to Extensions (
Ctrl+Shift+X). - Search for Schema Lens.
- Click Install.
- Open a supported schema file:
- SQL:
*.sql - Prisma:
schema.prisma - Drizzle: TypeScript files with
pgTable/mysqlTable/sqliteTable - Knex: TypeScript migration files with
createTable
- SQL:
- Click the ≋ ERD button in the editor title bar
or run Schema Lens: Open ERD from the Command Palette (Ctrl+Shift+P). - The ERD opens in a side panel next to your code.
- Zoom with the scroll wheel, pan by clicking and dragging the canvas.
- Save the file to refresh the diagram with your latest changes.
- Open a schema file.
- Run Schema Lens: Compare With… from the Command Palette.
- Choose a second schema file to compare.
- A diff ERD opens showing:
- 🟢 Added tables and columns
- 🔴 Removed tables and columns
- 🟡 Modified tables
| Format | File Pattern | Parser Approach |
|---|---|---|
| Raw SQL | *.sql |
node-sql-parser for CREATE/ALTER/FOREIGN KEY |
| Prisma | schema.prisma |
Line-based parser for model, fields, @relation |
| Drizzle | *.ts with pgTable / mysqlTable / sqliteTable |
TypeScript AST walk |
| Knex.js | *.ts with createTable |
TypeScript AST walk |
-
Internet on first use
Mermaid is loaded from a CDN the first time the ERD panel is opened. You can later bundle it locally if needed. [web:143] -
SQL dialect coverage
The SQL parser targets common PostgreSQL and MySQL syntax. Vendor-specific features such as SQL ServerIDENTITYmay fail to parse cleanly. -
Drizzle and Knex detection
For.tsfiles, Schema Lens auto-detects Drizzle vs Knex based on imports and function calls. If a file mixes both patterns, Drizzle is preferred. -
Prisma enums
enumblocks are currently ignored and do not appear in the ERD. -
Composite foreign keys
Fully supported in SQL parsing. ORM parsers handle the common patterns but some complex composites may not render perfectly yet. -
Views and procedures
Views, stored procedures, and functions are not parsed or shown in the diagram. -
Very large schemas
Diagrams with more than ~50 tables can feel heavy in the panel. Use zoom and pan to navigate large models efficiently. -
Inline SQL comments
Complex block comments (/* ... */) insideCREATE TABLEdefinitions can confuse the SQL parser in some cases.