
mermaid-to-image
Convert Mermaid code blocks in Markdown files to PNG images using the mermaid.ink API.
- Installs
- 4K
- Last 24h
- —
- Trending rank
- —
- Security
- Warn
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/zc277584121/marketing-skills --skill mermaid-to-image- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads mermaid-to-image automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
Skill: Mermaid to Image
Convert ```mermaid code blocks in Markdown (or other text) files into PNG images, and replace the code blocks with image references. Useful for platforms that don't render Mermaid natively (GitHub Pages/Jekyll, Dev.to, etc.).
When to Use
- The user asks to convert Mermaid diagrams in a file to images
- The user wants to render specific Mermaid code blocks as PNG
- A publishing workflow requires static images instead of Mermaid code blocks
Workflow
Step 1: Identify target files
The user may specify:
- A single file:
convert mermaid blocks in docs/architecture.md - Multiple files:
convert mermaid in all files under docs/ - A specific code block:
convert the second mermaid block in README.md
Scan the target file(s) for ```mermaid code blocks. Report how many blocks were found and in which files before proceeding.
Step 2: Determine the image output directory
Check the project structure to find where images are typically stored:
# Look for common image directories
ls -d images/ img/ assets/ assets/images/ static/images/ docs/images/ 2>/dev/null
If a clear image directory exists (e.g., images/, assets/images/), use it. Create a subdirectory by topic if appropriate (e.g., images/<topic>/).
If no image directory is obvious or multiple candidates exist, ask the user:
Where should I save the rendered Mermaid images?
1. images/ (create new)
2. assets/images/
3. docs/figures/
4. Custom — enter a path
Step 3: Render each diagram to PNG
Use the mermaid.ink API to render diagrams. Run this Python snippet for each block:
import base64, urllib.request
def render_mermaid(code: str, output_path: str):
"""Render a Mermaid diagram to PNG via mermaid.ink API."""
encoded = base64.urlsafe_b64encode(code.encode()).decode()
url = f"https://mermaid.ink/img/{encoded}?bgColor=white"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
resp = urllib.request.urlopen(req, timeout=30)
with open(output_path, "wb") as f:
f.write(resp.read())
Important: The User-Agent header is required — mermaid.ink returns 403 without it.
Naming convention
Use descriptive filenames based on the diagram content, not generic names:
- GOOD:
architecture-overview.png,data-flow.png,heartbeat-sequence.png - BAD:
mermaid-1.png,diagram.png,image1.png
Step 4: Replace code blocks with image references
Replace each ```mermaid ... ``` block with a Markdown image reference using a relative path from the file to the image:

If the project uses absolute URLs (e.g., GitHub Pages), use those instead:

Choose the link style that matches the project's existing image references. If unsure, use relative paths.
Step 5: Report results
After processing, summarize:
- How many diagrams were converted
- Where the images were saved
- Which files were modified
Edge Cases
- Large diagrams: mermaid.ink may time out on very complex diagrams. If a render fails, report the error and suggest the user simplify the diagram or try an alternative renderer.
- Multiple blocks in one file: process all blocks in order, give each a unique descriptive filename.
- Already-rendered blocks: if a mermaid block already has a corresponding image (commented out or adjacent), skip it or ask the user.
- Non-Markdown files: the same approach works for any text file containing mermaid code blocks (e.g.,
.rst,.txt).
FAQ
What does the mermaid-to-image skill do?
Convert Mermaid code blocks in Markdown files to PNG images using the mermaid.ink API.
How do I install mermaid-to-image?
Run npx skills add https://github.com/zc277584121/marketing-skills --skill mermaid-to-image in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/mermaid-to-image/ (personal) or .claude/skills/mermaid-to-image/ (project).
Which AI agents can use mermaid-to-image?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is mermaid-to-image safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk flagged items to review; ZeroLeaks passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains mermaid-to-image?
It is published by zc277584121 in zc277584121/marketing-skills. It has 3,965 recorded installs.
More from zc277584121/marketing-skills
remove-ai-style
zc277584121/marketing-skills
Aggressively rewrite Chinese or English prose to remove AI-generated patterns. Use for de-AI polishing, natural-language rewrites, robotic or formulaic writing, and publication cleanup. Always run the bundled deterministic Markdown analyzer first, remove every editable exclamation mark, dash, and formulaic binary contrast, inspect every other reported location, then read the full article for semantic patterns the rules cannot enumerate.
browser-screenshot
zc277584121/marketing-skills
Take focused, region-specific screenshots from web pages using a dedicated headed Chrome profile with persistent login state. Navigates to the right page based on user context (URL, search query, social media post), locates the target region via DOM selectors, and crops to a clean, focused screenshot without attaching to the user's daily browser.
content-rewrite
zc277584121/marketing-skills
Adapt and rewrite content for different platforms (LinkedIn, X, Reddit, English blog, WeChat). Each platform has its own tone, format, and length requirements.
chrome-automation
zc277584121/marketing-skills
Automate Chrome browser tasks using agent-browser CLI. Navigate pages, fill forms, click buttons, take screenshots, extract data, and replay Chrome DevTools Recorder exports.
image-generation
zc277584121/marketing-skills
Generate illustration images for articles and documentation with a Codex-first workflow, OpenAI API fallback, and Gemini fallback.
raw-video-processing
zc277584121/marketing-skills
Post-process raw screen recordings by removing silent segments and applying speed adjustments. Uses FFmpeg-based Python scripts to optimize video pacing automatically.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.