skillfed

mermaid-py

Python Interface for the Popular mermaid-js Library, Simplified for Diagram Creation.

mermaid-py v0.8.4 172.3K downloads/30d#10,342 on PyPI
Permissive license MIT Active released

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-py

uv

uv add mermaid-py

poetry

poetry add mermaid-py

Installing 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

python mermaid diagram generationflowchart creation pythonvisualization scriptingdiagram as code pythonmermaid syntax wrapperstate diagram pythonsequence diagram generator
diagram-as-codejupyter-integrationvisualization

More Graphics packages