If you love Mermaid diagrams — flowcharts, sequence diagrams, Gantt charts, pie charts, and more — but you’ve ever felt stuck because you had to install Node.js, npm, browsers, or other system tools just to generate diagram files, today is your day!
Say hello to mmdc, the Python‑native Mermaid diagram converter that finally lets you generate beautiful diagrams straight from Python — with no external installs, no system packages, and no extra runtime hassles! 🙌(github)
🧠 First — What Is Mermaid?
Mermaid is an open‑source diagramming tool that lets you define diagrams using simple, text‑based syntax — very similar to Markdown — and render them into real diagrams.
You write plain text like:
graph TD
A --> B
B --> C
…and Mermaid turns it into a visual flowchart you can embed in docs, wikis, blogs, or technical writing. It’s fast to learn, version‑control friendly, and integrates with many tools.
Mermaid has become super popular in documentation, engineering teams, and developer blogs precisely because diagrams become code — no GUI drag‑and‑drop tools, no files to manage manually — just text that lives with your project.(Mermaid)
🌟 Why mmdc Is a Game Changer
Traditionally, if you wanted to convert Mermaid into SVG, PNG, or PDF, you needed:
✔ Node.js
✔ npm
✔ Mermaid CLI
✔ Browsers or headless workers
✔ Extra system tools
That always felt like overkill for something as simple as turn text into a diagram.
mmdc changes all that. It’s a pure Python solution — installable with a single pip install, and it works without installing ANY external tools like system packages or browsers.
It uses the powerhouse library Phasma, which leverages an internal PhantomJS instance under the hood to render Mermaid code into real diagram outputs — yet you never have to install anything else yourself. This makes it perfect for Python environments, automation, docs pipelines, and CI/CD workflows.
🚀 Installation
Just run:
pip install mmdc
That’s all — you’re ready to go! No Node.js, npm, apt installs, or browsers required.
🌈 Use It from the Command Line
Convert a simple Mermaid file to SVG:
mmdc --input my_diagram.mmd --output my_diagram.svg
Create PNG or PDF just by specifying the extension:
mmdc --input my_diagram.mmd --output my_diagram.png
mmdc --input my_diagram.mmd --output my_diagram.pdf
Perfect for automated doc builds, static site generators, or even blog pipelines!
🐍 Use It in Python Too
Want to generate diagrams right inside your Python code? No problem:
from mmdc import MermaidConverter
converter = MermaidConverter()
mermaid_text = """
graph TD
A[Start] --> B{Is it cool?}
B -->|Yes| C[Love it!]
B ---->|No| D[Try again]
"""
converter.to_svg(mermaid_text, output_file="cool_diagram.svg")
Simple, powerful, and integrates cleanly with Python applications, docs generators, notebook workflows, and automation scripts!
📊 Example Mermaid Code Snippets
Here are a few Mermaid diagrams you can try:
📈 Flowchart
graph LR
A[Idea] --> B[Develop]
B --> C[Test]
C --> D[Deploy]
🔁 Simple Loop
flowchart TD
Start --> Process
Process --> Review
Review -->|OK| End
Review -->|Fix| Process
⏱️ Sequence Diagram
sequenceDiagram
Alice->>Bob: Hello Bob!
Bob-->>Alice: Hi Alice!
💡 Why This Matters
🧩 No external setup: Python devs finally get Mermaid without any extra installs.
🛠 Fits docs automation: Great for Sphinx, MkDocs, Jupyter, notebooks, and CI/CD.
📦 Python‑centric workflows: Treat diagrams as first‑class parts of your codebase.
🎉 Wrap Up
If you’ve ever wanted a clean, Python‑only way to generate Mermaid diagrams, mmdc is huge news. It brings a beloved text‑based diagramming approach straight into the Python ecosystem — all with a single pip install.
Now diagrams truly can be code first — versioned, automated, lightweight, and beautiful — without the weight of external toolchains. 💥
Top comments (0)