Language support for DBML (Database Markup Language) files in Visual Studio Code.
This extension is the editor frontend for
dbml-tools — a Go CLI that
ships an LSP server alongside its tosql, todot, migrate, and
check subcommands.
Blog: https://www.tqdev.com/2026-dbml-tools-vscode-extension-lsp/
- Syntax highlighting for tables, enums, refs, table groups, project settings, attributes, builtin types, strings, comments, color literals, and relationship operators.
- Live diagnostics — parse and semantic errors are surfaced as red squiggles as you type.
- Hover over a table, column, enum, alias, builtin type, or attribute to see its definition and constraints.
- Completions that adapt to context: top-level keywords, builtin types
and declared enums in column-type position, attribute names inside
[ … ], table names inRefendpoints, column names aftertable., inline-ref targets,TableGroupbody, andProject { database_type: … }values. - Go-to-definition (F12) on a ref endpoint, alias, or enum-as-type jumps to the underlying declaration.
- Find all references (Shift+F12) from any symbol.
- Rename (F2) across the whole file — tables, columns, enums, aliases,
ref names, table groups. Names that need quoting are wrapped in
"…"automatically. - Document outline — the file's tables and enums show up in VSCode's outline view and breadcrumb bar.
- Snippets for common shapes:
table,tablefk,ref,enum,proj,tg.
The extension talks to the Go binary via LSP. Install it with:
go install github.com/mevdschee/dbml-tools@latest
…or download a prebuilt binary from the
releases page and put
it on your $PATH. Verify with:
dbml-tools lsp --help 2>&1 | head -3
From the Marketplace:
Extensions panel → search "DBML Tools" → Install.
Or from a .vsix:
code --install-extension dbml-tools-0.1.0.vsix
The extension activates the first time you open a .dbml file.
All settings live under the dbml.* namespace.
| Setting | Default | What it does |
|---|---|---|
dbml.path |
"" |
Absolute path to the dbml-tools binary. Leave empty to use the binary on $PATH. |
dbml.trace.server |
off |
LSP protocol tracing: off, messages, or verbose. Output goes to the DBML channel. |
dbml.log.path |
"" |
If set, the server writes detailed logs to this file. Useful for filing bug reports. |
Binary resolution order: dbml.path → $PATH lookup → bundled
per-platform binary.
| Command | Default keybinding |
|---|---|
DBML: Restart language server |
— |
Run via Cmd/Ctrl+Shift+P.
Create schema.dbml and start typing:
Project myapp {
database_type: 'PostgreSQL'
}
Table users as u {
id int [pk, increment]
email varchar(255) [not null, unique]
status order_status
}
Enum order_status {
pending
shipped
cancelled
}
Ref: orders.user_id > u.id
Try:
- Hover over
order_statuson thestatuscolumn — you'll see the enum's values. - F12 on
u.idin theRefline — you'll jump to theuserstable. - F2 on
users— rename it everywhere in the file in one go. - Inside
[ … ], press Ctrl+Space — you'll seepk,unique,not null,default,note,ref, etc.
The most useful tool is the DBML output channel (View → Output →
DBML). Set dbml.trace.server to verbose to see every request and
response.
Common symptoms:
- "dbml-tools binary not found" — set
dbml.pathto an absolute path, or putdbml-toolson your$PATH. - Highlighting works but nothing else does — the grammar runs without
the server. If you see no diagnostics/hover/completions, the server
failed to start. Check the DBML output channel for errors, and confirm
the binary runs directly:
dbml-tools check schema.dbml. - Wrong positions / off-by-one — LSP positions are zero-based and
measured in UTF-16 code units. If positions look badly wrong with
non-ASCII identifiers, please file a bug with
dbml.trace.serverset toverboseand the captured trace attached.
For step-by-step development and debugging instructions, see DEBUG.md.
git clone git@github.com:mevdschee/dbml-tools-vscode.git
cd dbml-tools-vscode
npm install
npm run build # one-shot
npm run watch # auto-rebuild
Then press F5 in VSCode to launch an Extension Development Host with
the extension loaded. See DEBUG.md for the full workflow,
including how to point the extension at a locally built dbml-tools
binary.
Run the grammar tests:
npm run test:grammar
The grammar test files live under test/grammar/ and use the
vscode-tmgrammar-test inline-assertion format.
.
├── package.json Manifest + scripts
├── language-configuration.json Brackets, comments, auto-close
├── syntaxes/dbml.tmLanguage.json TextMate grammar
├── snippets/dbml.code-snippets Static snippets
├── src/extension.ts LSP client wiring
├── esbuild.config.js Bundler config
├── test/grammar/*.dbml Grammar tokenization tests
├── server-bin/ Per-platform `dbml-tools` binaries (CI fills)
└── DEBUG.md Local debugging guide
MIT.
dbml-tools— the CLI & language server.- DBML specification — the language this extension supports.
- Holistics/dbml — the upstream DBML project.