---
title: ToolRouter — Tool Detail
description: Detailed documentation for a ToolRouter tool including skills, parameters, and examples.
url: https://toolrouter.com/tools/diagram-generator
---
# Diagram Generator

Render diagrams from text source code in Mermaid, PlantUML, Graphviz DOT, D2, C4-PlantUML, ERD, DBML, and more. Returns SVG or PNG plus a permanent URL for embedding. Great for architecture, flowcharts, and sequence diagrams.

- **Version:** 0.02
- **Categories:** data, media

## Skills (1)

### Generate Diagram (`generate_diagram`)

Render a diagram from text source code. Accepts Mermaid, PlantUML, Graphviz DOT, D2, C4-PlantUML, ERD, DBML, and more. Returns a rendered image file plus a permanent URL for embedding.

**Parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `source` | string | Yes | The diagram source text in the specified diagram language |
| `type` | string | No | Diagram language (default "mermaid"). Supported: mermaid, plantuml, graphviz (DOT), d2, c4plantuml, erd, dbml, blockdiag, seqdiag, actdiag. (mermaid, plantuml, graphviz, d2, c4plantuml, erd, dbml, blockdiag, seqdiag, actdiag) [default: "mermaid"] |
| `format` | string | No | Output image format (default "svg"). SVG is scalable and includes the raw markup; PNG is a raster image. (svg, png) [default: "svg"] |

**Returns:** Rendered diagram image as a downloadable file plus a permanent URL for embedding

**Examples:**

*Mermaid flowchart showing a CI/CD pipeline:*

```json
{
  "source": "graph TD\n  A[Push Code] --> B[Run Tests]\n  B --> C{Tests Pass?}\n  C -->|Yes| D[Deploy to Staging]\n  C -->|No| E[Fix & Retry]\n  D --> F[Deploy to Production]",
  "type": "mermaid"
}
```

*PlantUML sequence diagram for user authentication:*

```json
{
  "source": "@startuml\nActor User\nUser -> App: Login Request\nApp -> AuthService: Validate Credentials\nAuthService --> App: JWT Token\nApp --> User: Login Success\n@enduml",
  "type": "plantuml"
}
```

*Graphviz DOT directed graph of microservices:*

```json
{
  "source": "digraph G {\n  rankdir=LR;\n  Gateway -> UserService;\n  Gateway -> OrderService;\n  OrderService -> PaymentService;\n  OrderService -> InventoryService;\n}",
  "type": "graphviz"
}
```

## Quick Start

```bash
# Via CLI
TOOLROUTER_API_KEY=tr_live_xxx npx -y toolrouter-mcp call diagram-generator generate_diagram --source graph TD
  A[Push Code] --> B[Run Tests]
  B --> C{Tests Pass?}
  C -->|Yes| D[Deploy to Staging]
  C -->|No| E[Fix & Retry]
  D --> F[Deploy to Production] --type mermaid

# Via REST API
curl -H "Authorization: Bearer tr_live_xxx" \
     -d '{"tool":"diagram-generator","skill":"generate_diagram","input":{"source":"graph TD\n  A[Push Code] --> B[Run Tests]\n  B --> C{Tests Pass?}\n  C -->|Yes| D[Deploy to Staging]\n  C -->|No| E[Fix & Retry]\n  D --> F[Deploy to Production]","type":"mermaid"}}' \
     https://api.toolrouter.com/v1/tools/call
```

## Frequently Asked Questions

### What kinds of diagrams can I generate?

`generate_diagram` supports Mermaid, PlantUML, Graphviz DOT, D2, C4-PlantUML, ERD, DBML, and similar text-based diagram formats.

### Do I get an image file or just text output?

You get a rendered SVG or PNG plus a permanent shareable URL, so the diagram can be embedded or downloaded after it is generated.

### What should I pass for the diagram type?

Pass the source code and the format type, and use `mermaid` if you want the default. SVG is the default output format for scalable diagrams.

### Is this good for architecture and flowcharts?

Yes. It is built for architecture diagrams, flowcharts, sequence diagrams, and other structured visuals where text source is easier to version than pixels.

---

## Get Started with ToolRouter

**Already connected?** Call any tool with `use_tool({ tool, skill, input })`. Browse tools with `discover` or visit https://toolrouter.com/llms-full.txt

**New to ToolRouter?** Connect with one command (no API key needed — auto-provisions on first use):

```bash
# MCP (Claude Code, Codex CLI)
claude mcp add toolrouter -- npx -y toolrouter-mcp

# MCP (Cursor, Windsurf, Cline, VS Code, Gemini CLI, Claude Desktop)
{"mcpServers":{"toolrouter":{"command":"npx","args":["-y","toolrouter-mcp"]}}}

# Claude Chat / Claude Cowork / Claude Mobile — add as a connector:
# Settings → Connectors → Add custom connector → URL: https://api.toolrouter.com/mcp

# ChatGPT — add as an app:
# Settings → Apps → Advanced settings → enable Developer mode → Create app → MCP Server URL: https://api.toolrouter.com/mcp

# CLI (works instantly, no restart needed)
npx -y toolrouter-mcp tools                    # browse all tools
npx -y toolrouter-mcp search "seo"             # search by keyword
npx -y toolrouter-mcp call seo analyze_page --url https://example.com
```

Free tools work immediately. For paid tools, visit https://toolrouter.com/claim to add credits.

All platforms: https://toolrouter.com/connect | Full catalog: https://toolrouter.com/llms-full.txt | Docs: https://toolrouter.com/docs