`mermaid-py` is a Python interface for the popular `mermaid-js` library, simplifying the creation and rendering of diagrams directly from Python code. It currently targets the latest `Mermaid.js v10+` and provides methods to output diagrams as HTML, JSON, or images. The current version is 0.8.4, with releases typically following major Mermaid.js updates or API improvements.
pip install mermaid-pyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a Mermaid diagram string, create a `Mermaid` object, and retrieve its HTML and JSON representations. Image generation is commented out as it requires additional external dependencies (Playwright) to be installed and configured.
Refer to the `mermaid-py` v0.8.0+ documentation for updated API usage, especially for `Mermaid` class instantiation and rendering methods. The `render()` method was removed.
Ensure your Mermaid diagram definitions adhere to `Mermaid.js v10+` syntax. Consult the official `Mermaid.js` documentation for valid syntax.
Install `playwright` (e.g., `pip install playwright`) and then run `playwright install chromium` to enable image rendering functionality.
Change your import statement from `from mermaid_py import Mermaid` to `from mermaid import Mermaid`.
`mermaid-py` v0.8.0+ no longer has a `render()` method. Use `to_html()`, `to_json()`, or `to_image()` on the `Mermaid` object directly to get the desired output.
Review your diagram string for typos, incorrect keywords, or improper structure. Refer to the official `Mermaid.js` documentation for correct syntax for your diagram type (e.g., graph, flowchart, sequence).
No dependency data recorded yet.