DBMLX: Database Visual and DesignDBMLX ( Your schema stays in plain text. The extension reads it, renders it, and persists your layout alongside it — reviewable in Git, portable across teams.
→ Full language reference — complete syntax, all constructs, migration diffs, DiagramView, layout format. InstallInstall from VSCode Marketplace — or download a
Open any
The .dbmlx Language
|
| Key | Format | Records |
|---|---|---|
name |
name="old" |
previous column name |
type |
type="old" |
previous column type |
default |
default="old" |
previous default value |
pk |
pk=true\|false |
pk status before the change |
not_null |
not_null=true\|false |
not-null status before |
unique |
unique=true\|false |
unique status before |
increment |
increment=true\|false |
auto-increment status before |
All modify:/before: keys combine freely with standard column settings in any order: [pk, not null, before: name="old", pk=false].
Features
Interactive diagram
- Every
Table,Ref, andTableGrouprenders as positioned nodes with Manhattan-routed edges. - Each FK edge exits from the source column row and enters at the target column row — not the table midpoint.
- Drag tables freely. Positions are saved to a sidecar
.dbmlx.layout.jsonafter a 300ms debounce. - Multi-select: click-drag on empty space for marquee.
Shift+marquee extends selection. Drag any selected table to move the group. - Drag the middle segment of any edge to reroute it. The offset persists in the layout file.
- Cardinality markers: crow's-foot for many (
*), bar for one (1).
DDD-aware bounded contexts
The Table Groups panel (top-left of the diagram) lists all TableGroups plus a No Group entry for ungrouped tables.
- Collapse a group to a single summary node — edges route to/from it.
- Hide a group to remove it and all its edges from the diagram.
- Hide all ungrouped tables via the No Group row's eye button.
- Assign custom colors per group by clicking the color swatch, or per table via the palette icon that appears on header hover.
- Search by group or table name — matching groups expand automatically.
- Click a group name to focus the viewport on that group's tables.
- Annotation filter chips — filter the list to tables with migration changes:
+NEW— tables with[add]annotationDROP— tables with[drop]annotationDIFF— tables that have any column-level diff annotation ([add],[drop],[modify:], or[before:])- Chips combine with the search query (OR logic within chips). A colored dot on each table row indicates its annotation state.
Diagram Views
Switch between named views from the toolbar. Each view filters tables, groups, and schemas independently and has its own layout file.
Layout persistence
Positions, viewport, group state, and edge offsets live in schema.dbmlx.layout.json next to your schema:
{
"version": 1,
"viewport": { "x": 0, "y": 0, "zoom": 1.0 },
"tables": { "public.users": { "x": 120, "y": 80 } },
"groups": { "billing": { "collapsed": true, "color": "#D0E8FF" } }
}
Keys are alphabetically sorted, integers for coordinates, defaults omitted — minimal, reviewable Git diffs.
Performance
- Spatial index + viewport culling: only visible tables render.
- LOD rendering: full detail at ≥60% zoom, header-only at 30–60%, bounding box below 30%.
- Targets 60fps pan/zoom with 5000+ tables.
LSP intelligence
Full language server features for .dbmlx files:
| Feature | Details |
|---|---|
| Hover | Table schema with column diff state; keyword docs for every construct including [add], [drop], [modify:], [before:] |
| Go-to-definition | Jump to table or column definition; !include → open included file |
| Document symbols | Outline panel lists all tables and columns |
| Completions | Table names, column names, SQL types, settings, ref operators, diff annotations, !include file paths; Ref: completions chain automatically: schema → table → column → operator → right-side schema/table/column without Ctrl+Space; composite FK tuple syntax supported |
| CodeLens | "Focus in diagram" link above each Table definition — click to pan and zoom the open diagram to that table, un-hiding its group if needed |
| Code actions | Convert between top-level Ref: and inline [ref: ...] (both directions). Lightbulb on a Ref: line offers attaching to either endpoint, FK side first by convention. Lightbulb on a column with [ref: ...] lifts it to a top-level Ref: (FK on right). Migration annotations ([add]/[drop]) round-trip; composite refs are not convertible (DBML inline refs are single-column). |
| Formatting | Auto-format on save — consistent indentation, idempotent |
| Diagnostics | Parse errors shown as squiggles with line/column |
Diagram toolbar
The actions panel (bottom of the diagram) provides view toggles:
| Toggle | Default | Effect |
|---|---|---|
| PK/FK only | Off | Show only primary key and foreign key columns |
| Table Groups | On | Show group boundary boxes; auto-arrange respects group clusters |
| Cardinality | On | Show 1/N labels on relation lines |
| Merge Lines | On | Merge FK lines that share the same endpoint column into a single trunk with a junction dot |
Column hover highlight
Hover any column in the diagram to instantly highlight all FK relationships involving that column:
- The hovered column and all connected columns across tables get an amber background.
- Related edges turn yellow and thicken; unrelated edges dim to near-invisible.
- Junction dots on merged trunk lines follow the same highlight/dim state.
Edge hover tooltip
Hover any relation line to see a tooltip showing source.col → target.col and the cardinality (N : 1, 1 : 1, etc.).
Auto-arrange
Four layout algorithms available from the arrange button (⟳):
| Algorithm | Best for |
|---|---|
| Top-down | Most diagrams — relationships flow top to bottom |
| Left-right | Long lineage chains, ETL pipelines |
| Snowflake | Dense graphs, data warehouses |
| Compact | Schemas with few relationships |
When Table Groups is enabled, auto-arrange clusters tables from the same group together.
Export
- SVG / PNG: full fidelity — tables, edges, markers, cardinality labels, group containers, migration diff colors.
- SQL: export the schema to MySQL, PostgreSQL, or SQL Server DDL.
- Import from SQL: convert MySQL, PostgreSQL, or SQL Server DDL to
.dbmlx.
Run the relevant command from the command palette or use the export buttons in the diagram toolbar.
Commands
| Command | Shortcut |
|---|---|
| DBMLX: Open Diagram | — |
| DBMLX: Auto Re-arrange Diagram | — |
| DBMLX: Fit to Content | Ctrl+1 / Cmd+1 |
| DBMLX: Reset View | Ctrl+0 / Cmd+0 |
| DBMLX: Zoom In | Ctrl+= / Cmd+= |
| DBMLX: Zoom Out | Ctrl+- / Cmd+- |
| DBMLX: Export Diagram as SVG | — |
| DBMLX: Export Diagram as PNG | — |
| DBMLX: Export Schema to SQL | — |
| DBMLX: Import Schema from SQL | — |
| DBMLX: Focus Table in Diagram | — (use CodeLens link above Table definition) |
Layout file
The sidecar schema.dbmlx.layout.json is intentionally human-readable and Git-friendly:
- Stable key ordering — no noisy diffs when positions don't change.
- Integers only for coordinates — no floating-point drift.
- Defaults omitted —
collapsed: falseandhidden: falseare not written. - Atomic writes — tmp file → rename, no partial writes.
- Per-view files — named views get their own
schema.dbmlx.<viewName>.layout.json.
Commit this file alongside your schema. Your team sees the same diagram layout on checkout.
Credits
- Forked from TWulfZ/dddbml — original Git-friendly DBML diagram renderer.
- DBML language and
@dbml/coreparser by Holistics (Apache-2.0). - Layout engine:
@dagrejs/dagre. - Rendered with Preact + Zustand.
- LSP intelligence, migration diff visualization, SQL import/export, diagram views, and all extended features built with Claude Code by Anthropic.