Quickly generate high-quality mind maps (XMind format) from images or documents.
Execution Steps
When the user needs to convert an image or document into a mind map, follow these steps:
1. Confirm the input file
Get the file path the user wants to process. Supported formats:
- Images: PNG, JPG, JPEG, GIF, WebP (Claude directly analyzes the image structure)
- Documents: TXT, MD, DOCX, PDF (after reading the content, analyze and generate the hierarchy)
If the user does not specify a path, ask for the file location.
2. Understand personalized requirements (optional)
Ask the user whether they have any special requirements, for example:
- Hierarchy depth (e.g., "generate a 4-level structure")
- Key focus (e.g., "emphasize the technical implementation")
- Organization method (e.g., "arrange in chronological order")
3. Use Claude to generate the mind map content
For image input: Directly analyze the image, extract all hierarchical structures, and generate a Markdown-format mind map outline.
For document input:
- Read the document content (use the document reader tool to process DOCX/PDF when necessary)
- Analyze the document structure and extract the core topics and subtopics
- Generate a clearly hierarchical Markdown outline
When generating Markdown, you must follow:
- Use
#as the main title - Use
##,###,####to indicate hierarchy - Do not add bold, lists, or other formatting
- Structure example:
# 主题标题
## 一级分支
### 二级分支
#### 三级分支
## 另一个一级分支
4. Convert to XMind format
Use the markdown_to_xmind() function to convert Markdown into a .xmind file:
import sys
sys.path.insert(0, '/Users/lius/Code/md2xmind')
from lib.xmind_generator import markdown_to_xmind
markdown_to_xmind(markdown_content, output_path, title)
5. Report the results
- Save the Markdown file (.md)
- Save the XMind file (.xmind)
- Tell the user they can open it with XMind software
Tool Functions
1. Generate XMind file (editable)
import sys
sys.path.insert(0, '/Users/lius/Code/md2xmind')
from lib.xmind_generator import markdown_to_xmind
markdown_to_xmind(
markdown_content, # 生成的 Markdown 内容
"/path/to/output.xmind", # 输出路径
"标题" # 思维导图标题
)
2. Generate image file (easy to share)
import sys
sys.path.insert(0, '/Users/lius/Code/md2xmind')
from lib.markdown_to_image import markdown_to_image
import asyncio
# 生成 PNG 图片(无需 XMind 软件即可查看)
asyncio.run(markdown_to_image(
markdown_content, # Markdown 内容
"/path/to/output.png", # 输出路径(支持 PNG/JPG)
"标题" # 思维导图标题
))
3. Complete workflow (recommended)
Generate all three formats at the same time so users can use them as needed:
import sys
import asyncio
sys.path.insert(0, '/Users/lius/Code/md2xmind')
from lib.xmind_generator import markdown_to_xmind
from lib.markdown_to_image import markdown_to_image
# 假设 markdown_content 已经生成
title = "思维导图标题"
base_path = "/path/to/output"
# 1. 保存 Markdown
with open(f"{base_path}.md", 'w', encoding='utf-8') as f:
f.write(markdown_content)
# 2. 生成 XMind(可编辑)
markdown_to_xmind(markdown_content, f"{base_path}.xmind", title)
# 3. 生成图片(易分享)
asyncio.run(markdown_to_image(markdown_content, f"{base_path}.png", title))
print(f"✅ 已生成:{base_path}.md / .xmind / .png")
Environment Requirements
- Python 3.7+
- Claude Code environment (AI analysis directly uses the current Claude session)
- Image generation dependency (Playwright):
pip install playwright playwright install chromium - XMind conversion dependency:
/Users/lius/Code/md2xmind/lib/xmind_generator.py
No external API Key is required; the AI analysis part is completed directly using Claude's own capabilities.
Output Formats
Generate all three formats at the same time to meet the needs of different scenarios:
| Format | File Extension | Use | Requires Additional Software |
|---|---|---|---|
| Image | .png |
Quick viewing, sharing, inserting into documents | No, can be opened on any device |
| XMind | .xmind |
In-depth editing, adjusting layout | Requires XMind software |
| Markdown | .md |
Secondary editing, version management | A text editor is sufficient |
Recommended usage strategy:
- Toshare/preview → use PNG images
- Toedit and adjust → use XMind format
- Tomodify content → use Markdown format
Notes
- Image quality affects AI recognition accuracy; it is recommended to use clear images with readable text
- When the document is long, the first 50000 characters will be automatically truncated for processing
- A valid OpenRouter API Key is required
- Generated files are saved in the directory of the input file (or the specified output directory)