diagram-to-image
Skill139 starsChanged 9 months agoMITView on GitHub
Convert Mermaid diagrams and Markdown tables to images (PNG) for platforms that don't support rich formatting. Use when user asks to "convert to image", "export as PNG", "make this an image", or has content for X/Twitter that needs visual exports.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- zju-zhanglu/diagram-to-imagetheir own version, first seen Jun 26, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- zju-zhanglu/diagram-to-image★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-feishuSkill
- claude-session-managerSkill
- codex-cliSkill
- codex-session-managerSkill
- cover-designSkill
- cover-imageSkill
- fpl-copilotSkill
- interactive-inputSkill
- mining-session-skillsSkill
- Next.js Security ScanSkill
- personal-chinese-writing-styleSkill
- producing-videoSkill
- promote-postSkill
- publish-substack-articleSkill
- publish-x-articleSkill
- publish-zsxq-articleSkill
- Python Security ScanSkill
- share-readingSkill
- slides-videoSkill
- subtitle-correctionSkill
- tweet-insightSkill
- video-plannerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 17 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill when:
- Distinctive: line 34
If user explicitly mentions a path or filename, use that.
- Distinctive: line 37
Check for common image/asset directories in the current project:
- Distinctive: line 44
Use the first existing directory found.
- Distinctive: line 53
If user is writing an article or document:
- Distinctive: line 54
Look for the document's directory
- Very specific: line 55
Create images/ subdirectory if appropriate
- Distinctive: line 65
If no context clues:
- Distinctive: line 66
Use current working directory
- Distinctive: line 71
Create meaningful filenames based on content analysis:
- Distinctive: line 84
Use kebab-case (lowercase with hyphens)
- Distinctive: line 85
Keep names concise but descriptive (2-4 words)
- Very specific: line 86
Avoid generic names like diagram.png or image.png
- Distinctive: line 93
Before converting, gather context:
- Distinctive: line 94
Check current working directory
- Distinctive: line 95
Look for existing image directories
- Distinctive: line 97
Consider any files or topics mentioned in conversation
- Distinctive: line 163
After conversion, tell the user:
- Very specific: line 229
Action: Use exactly ~/Desktop/my-chart.png as output path.
- Distinctive: line 233
If the API server is unreachable, the script prints a clear error message
- Very specific: line 234
If content type auto-detection fails, use --type mermaid or --type table explicitly
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Diagram to Image
Convert Mermaid diagrams and Markdown tables to PNG images via the mermaid-red API (diagramless.xyz). Produces high-quality, styled output with custom themes — no heavy local dependencies needed.
When to Use
Use this skill when:
- User has a Mermaid diagram that needs to be converted to an image
- User has a Markdown table that needs to be converted to an image
- User is writing content for X/Twitter and needs visual exports
- User asks to "convert to image", "export as PNG", "make this an image", or similar
Prerequisites
The bundled script uses Node.js built-in fetch (Node 18+). No npm install needed.
# The render script is bundled with this skill:
SKILL_DIR=~/.claude/skills/diagram-to-image/scripts
ls $SKILL_DIR/diagram-to-image.mjsSmart Output Location
IMPORTANT: Determine the best output location based on context. Follow this decision tree:
1. User Specifies Path
If user explicitly mentions a path or filename, use that.
2. Project Context Detection
Check for common image/asset directories in the current project:
# Check for existing image directories (in order of preference)
ls -d ./images ./assets ./img ./static ./public/images ./assets/images 2>/dev/null | head -1Use the first existing directory found. Common patterns:
./images/- General projects./assets/- Web projects./assets/images/- Structured web projects./public/images/- Next.js, React projects./static/- Hugo, other static site generators./img/- Short form convention
3. Article/Document Context
If user is writing an article or document:
- Look for the document's directory
- Create
images/subdirectory if appropriate - Name the image based on the document name + descriptor
4. Conversation Context
Analyze the conversation to determine:
- What the diagram represents → Use for filename (e.g.,
auth-flow.png,user-journey.png) - Related file being discussed → Place image near that file
- Topic being discussed → Use for naming
5. Default Fallback
If no context clues:
- Use current working directory
- Generate descriptive filename from diagram content
Filename Generation
Create meaningful filenames based on content analysis:
| Content Pattern | Example Filename |
flowchart with auth/login | auth-flow.png |
sequenceDiagram with API | api-sequence.png |
erDiagram | entity-relationship.png |
pie chart about X | x-distribution.png |
gantt chart | project-timeline.png |
| Table with comparison | comparison-table.png |
| Table with data | data-table.png |
Rules:
- Use kebab-case (lowercase with hyphens)
- Keep names concise but descriptive (2-4 words)
- Avoid generic names like
diagram.pngorimage.png - Include topic/subject when identifiable
Conversion Process
Step 1: Analyze Context
Before converting, gather context:
- Check current working directory
- Look for existing image directories
- Analyze diagram/table content for naming
- Consider any files or topics mentioned in conversation
Step 2: Determine Output Path
# Example logic (implement mentally, not as literal script)
if user_specified_path:
output_path = user_specified_path
elif exists("./images"):
output_path = "./images/{generated_name}.png"
elif exists("./assets"):
output_path = "./assets/{generated_name}.png"
elif exists("./public/images"):
output_path = "./public/images/{generated_name}.png"
else:
output_path = "./{generated_name}.png"Step 3: Create Temporary Input File
# For Mermaid diagrams
cat > /tmp/diagram.mmd << 'DIAGRAM_EOF'
<mermaid content>
DIAGRAM_EOF
# For Markdown tables
cat > /tmp/table.md << 'TABLE_EOF'
<table content>
TABLE_EOFStep 4: Convert via mermaid-red API
The API auto-detects content type (mermaid vs table). Both use the same command.
Using the bundled script:
# Mermaid diagram
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o <output_path>.png
# Markdown table
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o <output_path>.png
# With custom theme
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o <output_path>.png --theme ocean
# Force content type (if auto-detect gets it wrong)
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o <output_path>.png --type tableAvailable options:
--theme <name>— default, dark, forest, neutral, ocean, emerald, midnight, slate, lavender, blueprint--type <type>— auto (default), mermaid, table--scale <n>— 1-4 (default: 2, for 2x DPI)--bg <color>— Background color (default: white, use "transparent" for no bg)--server <url>— Override server (default: https://diagramless.xyz)
Piping from stdin also works:
echo "graph TD; A-->B" | node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs -o out.png
cat /tmp/table.md | node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs --type table -o table.pngStep 5: Report Result
After conversion, tell the user:
- Full path where image was saved
- Why that location was chosen (briefly)
- File size in bytes (printed by the script)
- Suggest they can specify a different location if needed
Examples
Example 1: Project with images/ directory
Context: User is in a project that has ./images/ directory, discussing authentication.
User: "Convert this to an image"
flowchart TD
A[Login] --> B{Valid?}
B -->|Yes| C[Dashboard]
B -->|No| D[Error]Action:
- Detect
./images/exists - Analyze content → authentication flow
- Generate filename:
login-flow.png - Save content to
/tmp/diagram.mmd - Run:
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o ./images/login-flow.png
Example 2: Writing X article about AI with ocean theme
Context: User mentioned writing an article about AI agents for X.
User: "Make this a PNG with ocean theme"
flowchart LR
User --> Agent --> Tools --> ResponseAction:
- Save content to
/tmp/diagram.mmd - Run:
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o ./ai-agent-flow.png --theme ocean
Example 3: Data comparison table
User: "Export this table as image"
| Model | Speed | Accuracy |
|-------|-------|----------|
| GPT-4 | Slow | High |
| Claude | Fast | High |Action:
- Save content to
/tmp/table.md - Run:
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o ./model-comparison.png(auto-detects as table)
Example 4: User specifies location
User: "Save this diagram to ~/Desktop/my-chart.png"
Action: Use exactly ~/Desktop/my-chart.png as output path.
Error Handling
- If the API server is unreachable, the script prints a clear error message
- If content type auto-detection fails, use
--type mermaidor--type tableexplicitly - For local development/testing, use
--server http://localhost:3000
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

