mermaid-py
Python Interface for the Popular mermaid-js Library, Simplified for Diagram Creation.
What it is and what it does
mermaid-py wraps the Mermaid JavaScript library to let Python developers generate diagrams using Mermaid's declarative syntax. You write diagram definitions as strings or use Python classes to build them, and the library renders them via the mermaid.ink service (or a self-hosted instance). It integrates with Jupyter notebooks to display diagrams inline and supports flowcharts, sequence diagrams, state diagrams, entity-relationship diagrams, user journeys, pie charts, requirement diagrams, and mindmaps.
The package depends only on requests to communicate with the rendering service. It's designed for developers who want to embed diagram generation in Python scripts or notebooks without learning a separate diagramming tool or leaving their Python environment.
Use it for:
- Generate flowcharts and state diagrams programmatically in Jupyter notebooks for documentation or analysis
- Create sequence diagrams to visualize system interactions or API call flows in Python applications
- Build entity-relationship diagrams from data schemas or database designs within Python workflows
- Embed diagram generation in Python scripts to produce visual outputs for reports or dashboards
- Use mindmaps or user journey diagrams to plan and visualize project workflows interactively
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
mermaid-py provides a Python interface to the Mermaid diagram library, letting you create flowcharts, state diagrams, sequence diagrams, and other visualizations by writing Mermaid syntax in Python.
Yes, if you need to generate Mermaid diagrams from Python and work in Jupyter notebooks or can tolerate an external rendering service dependency. The low install friction, permissive license, and active maintenance make it a straightforward choice. However, note that diagram type support is incomplete (several diagram types remain unimplemented), and reliance on mermaid.ink for rendering may be a concern in offline or high-security environments.
Install
mermaid-py on PyPI
pip
pip install mermaid-pyuv
uv add mermaid-pypoetry
poetry add mermaid-pyInstalling mermaid-py
Before you install
Low install friction with a single runtime dependency (requests). Maintenance status is active with a recent release.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions.
Quickstart
pip install mermaid-py
import mermaid as md
from mermaid.graph import Graph
render = md.Mermaid("""
flowchart LR
A-->B
B-->C
""")
render
Requires Python 3.9 or later. Notebook rendering requires HTML support in the environment.
Verify before relying
- Whether all diagram types listed as incomplete (Class, Gantt, Quadrant Chart, etc.) are actually unsupported or partially functional
- Performance characteristics when rendering large or complex diagrams
- Whether the mermaid.ink service dependency introduces reliability concerns for production use
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — requests |
| Maintenance | actively maintained — 158 days since the last release |
| First released | |
| Downloads | 172,262/month — #10,342 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mermaid_py-0.8.4-py3-none-any.whl
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
mermaid-builderProgrammatically generates MermaidJS diagram…
permissive · top 15,000 on PyPI
sphinxcontrib-mermaidEmbeds Mermaid diagrams (flowcharts, sequence…
permissive · top 5,000 on PyPI
django-diagramGenerates Entity Relationship Diagrams in…
unclear · top 15,000 on PyPI
mkdocs-mermaid2-pluginA MkDocs plugin that renders Mermaid diagram…
permissive · top 5,000 on PyPI
paracelsusParacelsus generates Entity Relationship…
permissive · top 15,000 on PyPI
mkdocs-panzoom-pluginAdds interactive pan and zoom functionality to…
permissive · top 5,000 on PyPI
mkdocs-kroki-pluginA MkDocs plugin that converts Kroki diagram…
permissive · top 15,000 on PyPI
schemdrawSchemdraw generates high-quality electrical…
permissive · top 15,000 on PyPI
wavedromConverts WaveDrom-compatible JSON…
permissive · top 15,000 on PyPI
diagramsDiagrams lets you draw cloud system…
permissive · top 5,000 on PyPI