SelDiA for VS Code
Self-Diagramming Architecture — A unified Diagram-as-Code extension with hand-drawn Rough.js aesthetics.
Create 21+ diagram types using a single, clean DSL directly in VS Code. Preview, edit, and export your diagrams — all without leaving the editor.
Features
🎨 21+ Diagram Types
Flowchart, Sequence, Class, C4 Context, C4 Container, BPMN, State, ER, Gantt, Mindmap, Component, Deployment, Network, Use Case, Activity, Chart (Bar/Line/Pie/Radar/Scatter), Sankey, Timeline, Git Graph, Form, Block — all in one unified DSL.
✏️ Interactive Editing
In the interactive editor for .sld files:
- Drag & drop nodes to reposition
- Double-click inline label editing
- Zoom & pan with scroll wheel and Shift+drag
- Right-click context menus for add/delete/edit
- Undo/redo (Ctrl+Z/Y) for visual edits
- Collapse/expand groups and C4 containers
Diagrams embedded in Markdown are laid out automatically and previewed
read-only; use "Open in editor" on a block to edit its DSL.
📝 Rich Language Support
- Syntax highlighting — Full TextMate grammar for
.sld files
- LSP diagnostics — Real-time error checking as you type
- Autocomplete — Keywords, diagram types, shapes, themes, edge types
- Hover documentation — DSL syntax reference on hover
- Go to definition — Navigate from node references to declarations
- Document symbols — Outline view of nodes, edges, and groups
- Code snippets — 16+ snippets for all diagram types
🔗 Markdown Integration
Embed SelDiA diagrams in any Markdown file:
```seldia
diagram flowchart "My Flow" {
start: (Start) --> process: [Process] --> end: (End)
}
```
- Auto-detects
```seldia fenced code blocks
- Inline SVG rendering in the editor
- CodeLens actions: "View Diagram", "Edit Code"
- Dedicated Markdown preview panel
🔄 Bidirectional Sync
Edit diagrams visually OR in code — changes sync both ways automatically. The source map preserves formatting, comments, and whitespace.
📄 PDF Export
Convert any Markdown file with embedded SelDiA diagrams to a professional PDF:
- Custom
marked renderer compiles DSL → SVG
- Print-optimized CSS with page breaks
- Auto-generated Table of Contents
- Error fallback rendering for broken diagrams
Getting Started
- Create a new file with the
.sld extension
- Start typing — autocomplete and diagnostics kick in
- Press
Ctrl+Shift+V to preview the rendered diagram
- Use
Ctrl+K V for a side-by-side code/preview view
Quick Examples
diagram flowchart "Hello World" {
start: (Start)
end: (End)
start --> end
}
diagram sequence "API Call" {
actor: (Client)
participant: [Server]
participant: [Database]
Client -> Server: POST /data
Server -> Database: INSERT
Database --> Server: OK
Server --> Client: 201 Created
}
Commands
| Command |
Keybinding |
Description |
| SelDiA: Toggle Code / Diagram View |
Ctrl+Shift+V |
Toggle between code and diagram |
| SelDiA: Open Preview to the Side |
Ctrl+K V |
Open preview side-by-side |
| SelDiA: Insert Diagram Block |
Ctrl+Shift+I |
Insert a SelDiA fenced block in Markdown |
| SelDiA: Export Diagram |
— |
Export current diagram as SVG/PNG/PDF |
| SelDiA: Export Markdown to PDF |
— |
Convert Markdown with diagrams to PDF |
Settings
| Setting |
Default |
Description |
seldia.defaultTheme |
sketchy-light |
Default theme for rendered diagrams |
seldia.markdown.enabled |
true |
Enable diagram detection in Markdown |
seldia.interactive.enabled |
true |
Enable interactive editing |
seldia.interactive.undoStackSize |
50 |
Maximum undo steps for visual edits |
seldia.export.defaultFormat |
svg |
Default export format |
Requirements
- VS Code 1.96.0 or later
- Node.js 22.x (for PDF export via Puppeteer — optional)
Extension Pack
This extension is part of the SelDiA ecosystem. Related packages:
Known Issues
- PDF export requires Puppeteer (installed on first use)
- Large diagrams (>200 nodes) may experience performance degradation
- Markdown injection grammar for syntax highlighting inside fenced blocks is pending
Enjoying SelDiA? Leave a review on the VS Code Marketplace! 🎉