Skip to main content

diagrams.mbt for Python

diagrams.mbt renders Mermaid diagrams to standalone SVG in your Python process. It uses the diagrams.mbt MoonBit renderer, compiled to native code. It needs no browser, no Node.js and no subprocess.

Experimental (0.0.x). The API can change in any release.

Install

pip install diagrams.mbt

Wheels are available for CPython 3.12 and later on:

Platform Wheel tag
Linux x86_64, glibc 2.17 or later manylinux_2_17_x86_64
Linux aarch64, glibc 2.17 or later manylinux_2_17_aarch64
macOS 11 or later, Apple silicon macosx_11_0_arm64
macOS 11 or later, Intel macosx_11_0_x86_64
Windows x86_64 win_amd64

Free-threaded CPython builds are not supported.

Render a diagram

import diagrams_mbt

result = diagrams_mbt.render_svg("""
flowchart TD
  A[Start] --> B{Ready?}
  B -->|Yes| C[Render]
""")

if result.ok:
    with open("diagram.svg", "w", encoding="utf-8") as f:
        f.write(result.output)

render_svg returns a Rendered value with output (the SVG text or None), media_type and diagnostics. It does not raise an exception for a diagram error:

result = diagrams_mbt.render_svg("flowchart TD\n  A[ --> B\n")
print(result.ok)               # False
for d in result.diagnostics:
    print(d.severity, d.code, d.message, d.span)

Supported Mermaid diagrams: flowchart and graph, sequence, state, ZenUML, architecture-beta and swimlane-beta.

Notes

  • Diagnostic columns and offsets count UTF-16 code units. Use diagrams_mbt.code_point_index(source, offset) to get a Python string index.
  • Calls hold the GIL and run one at a time.
  • An internal renderer failure (a MoonBit panic) stops the process. Do not render untrusted input in a process that must not stop.

See the Python documentation for details. The package is licensed under Apache-2.0. Bundled third-party components keep their own licenses; see the files in the licenses directory of the installed distribution.

Metadata

Release files for diagrams.mbt 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for diagrams.mbt 0.0.1
File Actions
diagrams_mbt-0.0.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for diagrams_mbt-0.0.1-cp312-abi3-win_amd64.whl
diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_x86_64.whl CPython 3.12 abi3 macOS 11.0+ x86-64 Details for diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_x86_64.whl
diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_arm64.whl

Total release size: 9.8 MB

Release files / diagrams_mbt-0.0.1-cp312-abi3-win_amd64.whl

Download URL diagrams_mbt-0.0.1-cp312-abi3-win_amd64.whl
Size 1.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c3f7822361b72268904361691961a0c54f2e60005e581c6ead0fff13d88719fe
BLAKE2b-256 checksum
How to use checksums
748b90785e20ade4153c6f8be6963f545470da255dde94232e30cef5566f8087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4db00dc2db58a39ea45c49bf7db6c8402a2c15d18d354a2a73d6df126d025b58
BLAKE2b-256 checksum
How to use checksums
9f3cf370295843a6cb3501dee11e01ea60f482fd58b0087ed460cda74042eb43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL diagrams_mbt-0.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7855eed52b1fa8b249a97afa8f2a1b8d6d9e8997b931075e7c473ce1931c93aa
BLAKE2b-256 checksum
How to use checksums
597f15fae66098f10df488675d4a2898e7270dc55cf04cb7093ce88eec934fef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_x86_64.whl

Download URL diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_x86_64.whl
Size 2.0 MB
Tags CPython 3.12 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
7de99519f276af26cc392c64517a14077a6c0f0024fb7290e99173c9850c6f08
BLAKE2b-256 checksum
How to use checksums
2c4c184c5918b351b4d6f3eac7db5077064b96518bc080f7b24f6a48b487ae30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL diagrams_mbt-0.0.1-cp312-abi3-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
792a6bc67bc511711275216679953a33e960f2a972c9fbdbb625898ff6be9128
BLAKE2b-256 checksum
How to use checksums
d134740015b19146874419d3f5456e599e193cd943318dd48413f1e9a27fddbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for diagrams.mbt 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for diagrams_mbt-0.0.1-cp312-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page