code-to-diagram
CTD Studio — local-first code-to-diagram editor & ctd-mcp server for Mermaid, DOT, PlantUML, D2, SQL, TypeScript, and XML
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 17 Nov 2026.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/cxernlol/code-to-diagram with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/cxernlol/code-to-diagram'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/cxernlol--code-to-diagram)HTML
<a href="/listings/cxernlol--code-to-diagram"><img src="/api/listings/cxernlol--code-to-diagram/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
git clone https://github.com/cxernlol/code-to-diagram.git cd code-to-diagram npm install npm run dev
Type-check and build for production:
npm run build
Run the Playwright end-to-end test suite:
npm test
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
README.md · README · 142 lines
- # CTD Studio
- [](https://github.com/cxernlol/code-to-diagram/actions/workflows/ci.yml)
- [](https://www.npmjs.com/package/ctd-mcp)
- [](LICENSE)
- Write diagram code, drag it into shape, export. No account, no server.
- **[Open the app ->](https://code-to-diagram.vercel.app/)** · **[Syntax & Template Docs ->](https://code-to-diagram.vercel.app/#docs)**
- Supports Mermaid, Graphviz DOT, PlantUML, D2, SQL DDL, TypeScript, and XML (Draw.io, BPMN). Your diagrams stay in your browser.
- ## Features
- - **7 input formats**, auto-detected, with one-click conversion between them
- - **Drag nodes and edges**, arrow-key nudging, grid snap, alignment guides
- - **One-click auto-arrange** and orthogonal edge routing
- - **Themes:** default, dark, forest, neutral, plus opt-in colorized boxes on export
- - **Local-first:** diagrams, layouts, and version history live in IndexedDB
- - **5-device live rooms:** share a live PeerJS session link to collaborate in real time
- - **Export** full-bounds SVG/PNG, or share a URL that keeps your manual layout
- - **Optional BYOK AI:** OpenAI, DeepSeek, Ollama, OpenRouter, Groq, or any compatible endpoint
- - **Syntax & template docs:** quick reference for arrows (`-->`, `-.->`, `==>`), shapes, 7-format syntax, and starter templates at [`#docs`](https://code-to-diagram.vercel.app/#docs)
- ## Supported Syntax
- All 7 formats are auto-detected and can be converted to Mermaid or translated across formats via the shared intermediate representation (`src/lib/formats.ts` and `src/lib/translate.ts`). Non-Mermaid formats support focused, practical subsets rather than full language specs:
- | Format | Extension | What is parsed & rendered | Notable omissions |
- | :--- | :--- | :--- | :--- |
- | **Mermaid** | `.mmd` | **Full Mermaid v12.3.0** for rendering. IR translation supports `flowchart`/`graph` (shapes, `TD`/`LR`, `-->`/`-.->`/`==>`/`---`/`<-->`), `classDiagram`, `erDiagram`, and `sequenceDiagram`. | Other Mermaid types (`gantt`, `pie`, `mindmap`, `gitGraph`, `C4*`, etc.) render natively but are not translated by the IR converter. |
- | **Graphviz DOT** | `.dot` | `(strict) (di)graph`, `rankdir` (`TB`/`TD`/`BT`/`RL`/`LR`), node `label` & `shape` (`diamond`, `circle`, `doublecircle`, `ellipse`, `oval`, `cylinder`), chained `->` / `--` edges with `label` & `style=dashed\|dotted`, `//` and `/* */` comments. | `subgraph` blocks, default `node`/`edge`/`graph` attribute statements, HTML-like labels, and `record` port layouts. |
- | **PlantUML** | `.puml` | `@startuml` blocks: **sequence** (`actor`/`participant`, `->`/`-->`/`->>`/`-->>` messages), **state** (`[*]` & `state` transitions), and **class** (`class`/`interface`/`enum`/`abstract class` blocks and `<\|--`, `*--`, `o--`, `-->`, `..>`, `..\|>`, `--` relations). | Activity, component, deployment, and use-case diagrams; `note`, `alt`/`loop` fragments, `package` nesting, and `skinparam` styling. |
- | **D2** | `.d2` | `direction` (`right`/`left`/`down`/`up`), nested `{ ... }` containers (`subgraph`), `id: label`, `id.shape: <shape>`, edges (`->`, `<-`, `<->`, `--`) with labels, and `#` comments. | `sql_table` / `class` shape blocks, `style` rules, `icon`, `link`, `near`, `grid-*`, and `vars`/`layers`/`scenarios`. |
- | **SQL DDL** | `.sql` | `CREATE TABLE [IF NOT EXISTS]` statements into `erDiagram` entities: column names & base types, `PRIMARY KEY` (`PK`), inline `REFERENCES`, table-level `FOREIGN KEY ... REFERENCES`, and `--` / `/* */` comments. | `ALTER TABLE`, views, indexes, `ENUM` declarations, triggers/functions, and `CHECK`/`UNIQUE` constraint details. |
- | **TypeScript** | `.ts` | `[export] interface`, `class`, and object `type Name = { ... }` declarations; `extends`/`implements` (`<\|--`), PascalCase property type references (`-->`), properties, methods, and `//` / `/* */` comments. | Generic type parameters (`<T>`), non-object union/intersection `type` aliases, `enum`s, functions, and imports. |
- | **XML** | `.xml` | **Draw.io / mxGraph** (`mxCell` vertices & edges), **BPMN 2.0** (`sequenceFlow`, events, gateways, tasks), explicit `<diagram>`/`<graph>`/`<schema>` (`<node>`/`<table>`/`<class>` + `<edge>`/`<relation>`), and **generic XML** as a hierarchical tree. | Draw.io styling/coordinates beyond basic shapes & dashed edges; BPMN pools/lanes/message flows; XML namespaces/XSD validation. |
- ## Getting Started
- ```bash
- git clone https://github.com/cxernlol/code-to-diagram.git
- cd code-to-diagram
- npm install
- npm run dev
- ```
- Type-check and build for production:
- ```bash
- npm run build
- ```
- Run the Playwright end-to-end test suite:
- ```bash
- npm test
- ```
- ## CTD Studio MCP Server (`ctd-mcp` via `npx`)
- `ctd-mcp` is the Model Context Protocol (MCP) server ([`mcp/`](mcp/README.md)) bundled with this repo, reusing the same multi-format parsers and translators. Use it in **Claude Desktop**, **Cursor**, **Windsurf**, **VS Code**, **Claude Code**, or directly from your terminal.
- Run directly via `npx` (`ctd-mcp` on npm):
- ```bash
- npx -y ctd-mcp
- ```
- ### Claude Desktop / Cursor / Windsurf
- Add to `claude_desktop_config.json`, `.cursor/mcp.json`, or `mcp_config.json`:
- ```json
- {
- "mcpServers": {
- "ctd-mcp": {
- "command": "npx",
- "args": ["-y", "ctd-mcp"]
- }
- }
- }
- ```
- ### VS Code (`.vscode/mcp.json`)
- ```json
- {
- "servers": {
- "ctd-mcp": {
- "type": "stdio",
- "command": "npx",
- "args": ["-y", "ctd-mcp"]
- }
- }
- }
- ```
- ### Available MCP Tools & Resources
- - **Tools:** `detect_format`, `to_mermaid`, `translate_format`, `parse_diagram_ir`, `emit_from_ir`, `list_templates`, `get_studio_info`
- - **Resources & Prompt:** `ctd://formats`, `ctd://themes`, `ctd://templates/{name}`, `code_to_diagram`
- - **MCP Safety:** `ctd-mcp` runs purely in-memory over stdio and **does not use filesystem or network APIs**. As with any text tool, untrusted diagram labels passed to an assistant remain untrusted text.
- Example output from `npx -y ctd-mcp` (`to_mermaid` on SQL DDL):
- ```mermaid
- erDiagram
- users {
- int id PK
- text email
- }
- diagrams {
- int id PK
- int user_id FK
- text title
- }
- users ||--o{ diagrams : references
- ```
- Build and test the MCP server locally:
- ```bash
- npm run mcp:build
- npm run mcp:test
- ```
- ## Tech Stack & CI/CD
- - **Stack:** TypeScript, React 19, CodeMirror 6, D3 (`d3-selection`, `d3-zoom`), PeerJS (5-device live rooms), and **Mermaid v12.3.0** (bundled locally in `public/mermaid.min.js` for offline reliability and consistent SVG DOM selectors when dragging nodes and edges).
- - **CI/CD:** GitHub Actions ([`.github/workflows/ci.yml`](.github/workflows/ci.yml)) runs type-checking, web and `ctd-mcp` builds, MCP stdio tests, and Playwright E2E tests on every push and pull request to `main` (see the CI badge above). Releases publish `ctd-mcp` to npm via [`.github/workflows/publish-mcp.yml`](.github/workflows/publish-mcp.yml).
- ## Data & Privacy
- - **Storage:** Diagrams, layouts, and preferences stay in your browser's IndexedDB. Legacy `mstudio2` `localStorage` data is migrated on first load while keeping a recovery copy.
- - **AI Requests & Keys:** API keys are stored in your browser only and are never included in share URLs. Prompts, diagram source, and keys are sent directly from your browser to the endpoint you configure.
- - **Cost:** CTD Studio is free to run and has no accounts or paid tiers. If you connect a commercial AI API key, provider usage is billed by that provider.
- ## Contributing
- All changes go through Pull Requests. See [CONTRIBUTING.md](CONTRIBUTING.md) for strict scope boundaries, local-first rules, and required checks before opening a PR.
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.