Format your .dbml
files with one click inside VS Code!
Automatically parse and format your Database Markup Language (DBML) files for clean, consistent, and readable schemas.
Table of Contents
Features
- Single-Command Formatting: Use the standard VS Code “Format Document” command to instantly reformat your DBML file.
- DBML Validation: Leverages @dbml/core internally to parse your file, ensuring it’s syntactically correct.
- No Reordering of References: Keeps your references exactly where you placed them, only adjusting spaces and indentation (according to the code you’ve integrated).
- Indentation & Spacing: Removes excessive whitespace and enforces consistent spacing around tokens.
- Smooth Integration: Automatically activates when you open a
.dbml
file in Visual Studio Code.
Installation
- Search for “DBML Formatter” in the Visual Studio Code Marketplace.
- Click “Install”.
- Reload your editor if prompted.
Or, install via CLI:
code --install-extension dbml-formatter.vsix
Usage
- Open any
.dbml
file in VS Code.
- Press
Shift + Alt + F
(Windows) or Shift + Option + F
(macOS) or Ctrl + Shift + I
(Linux) to format the document.
- Save your changes. Enjoy a clean DBML file!
You can also right-click in the editor and select:
Format Document
Or search the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
) for:
Format Document
Configuration
- Error Handling: If the parser encounters invalid DBML, the formatter will notify you in VS Code with an error message.
Sample
Below is a quick before-and-after snippet:
Before:
Table users {
_id ObjectId [primary key]
firstName string [not null]
lastName string [not null]
...
}
After:
Table users {
_id ObjectId [primary key]
firstName string [not null]
lastName string [not null]
...
}
Contributing
- Fork this repo.
- Clone your fork locally.
- Install dependencies:
npm install
- Make your changes (bug fixes, features, docs).
- Commit and push to your fork.
- Open a Pull Request describing your changes.
We welcome PRs for new features, bug fixes, or improvements in formatting logic!
License
This extension is provided under the MIT License. See the LICENSE file for details.
Happy Formatting!
DBML Formatter – Because your DBML deserves the best.