Skip to main content

maccha

Render Mermaid diagrams to SVG or PNG from Python. The renderer is written in Rust and compiled into the package: no browser, no Node.js, no other Python dependencies.

pip install maccha

It supports Python 3.9 and newer. One wheel per platform (Linux, macOS and Windows) serves every Python version.

Use it

import maccha

svg = maccha.render_svg("flowchart LR; A-->B-->C")            # str
png = maccha.render_png("flowchart LR; A-->B-->C", scale=2)   # bytes
dark = maccha.render_png("flowchart LR; A-->B", theme="dark", background="#1e1e1e")

open("out.svg", "w", encoding="utf-8").write(svg)
open("out.png", "wb").write(png)

Every argument after the diagram source is keyword-only:

Argument Applies to Meaning
theme both None (default), "default", "dark", "forest", "neutral" or "modern". Like mmdr -t: None leaves the theme to config["theme"], then to the built-in default; a name wins over config.
config both A dict like the JSON file given to mmdr -c (theme, themeVariables, flowchart, ...). A diagram's own %%{init}%% wins over it.
fonts both A maccha.Fonts(system=True, files=[], dirs=[], data=[]) to add fonts, or to ignore the system's (system=False)
strict_fonts both Raise RenderError if some text has no font that covers it
scale PNG Pixels per SVG unit; default 2.0
background PNG A hex color: "#ffffff" (#rgb, #rrggbb or #rrggbbaa; "#00000000" is transparent). Names such as "white" raise RenderError. Default is the theme's background.

For the same diagram, render_svg returns exactly what mmdr -e svg writes, and render_png(src, scale=1.0) what mmdr -e png writes.

Errors and warnings

try:
    maccha.render_svg("flowchart LR; A--")
except maccha.MermaidSyntaxError as e:    # a ValueError
    print(e.line, e.col, e.message)          # 1-based; col is 0 if unknown
  • MermaidSyntaxError: the diagram is not valid. It has line, col and message.
  • RenderError: any other failure, such as strict_fonts=True with missing glyphs.
  • MissingGlyphWarning: a UserWarning raised through warnings.warn when some text has no font that covers it.

The GIL is released while a diagram renders, so threads can render in parallel.

Fonts

A Noto Sans Khmer font (SIL Open Font License 1.1) is built in, so Khmer text renders with no font installed. For Japanese, Chinese, Korean or Thai text, the machine needs a font that covers it, or pass one with Fonts(files=[...]).

SVGs name their fonts but do not embed them; PNGs are drawn with the fonts that were measured.

MIT license. The bundled font's license is included in the wheel.

Metadata

Release files for maccha 0.1.0

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

Source distribution (sdist)

Source distribution for maccha 0.1.0
File Size Uploaded Provenance Actions
maccha-0.1.0.tar.gz 977.4 kB With provenance Details for maccha-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for maccha 0.1.0
File Actions
maccha-0.1.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for maccha-0.1.0-cp39-abi3-win_amd64.whl
maccha-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for maccha-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
maccha-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for maccha-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
maccha-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for maccha-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
maccha-0.1.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for maccha-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
maccha-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for maccha-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 29.7 MB

Release files / maccha-0.1.0.tar.gz

Download URL maccha-0.1.0.tar.gz
Size 977.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d1585664d14079f9036aa3ba858b671a017501612a9d95726a794f27c397e9be
BLAKE2b-256 checksum
How to use checksums
e103bbf094c44f6506ed232d7088e488857f0c814fd267f344a88d5bf8a31fa3
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-win_amd64.whl

Download URL maccha-0.1.0-cp39-abi3-win_amd64.whl
Size 4.8 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
31b435e5505e6565c7c029de22b89a21ca7e0711147ad6f9bee816e6712dfb92
BLAKE2b-256 checksum
How to use checksums
f5ab6c6b86541667fc6cab6018b3ce940de667e6b443fc53ae1c2244fc52873d
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL maccha-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 5.2 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
2529853c8c9211491b84f0e78fa2cae6e87b30339a8554efb950bf97d1944235
BLAKE2b-256 checksum
How to use checksums
937757bfc5105d918fbdbd758aa332d08ae89191f473a0e76b90007239ef83d9
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL maccha-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 5.0 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6010614c1ed59ea00134a0a94d81dc1e9e2f392ed5d3d698a6000fb4a54ab616
BLAKE2b-256 checksum
How to use checksums
e6e3b8a4db13bc5f046a8bcb9b7bad3ade3f7a64175be5ca928ddf808a364d89
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL maccha-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 4.7 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
fcec5659fb25428857acbc057c4e228c196569a25dafdd6c3434215b5b98bf88
BLAKE2b-256 checksum
How to use checksums
9824195f5b00d6a415a5483c7064260479aa7de58de7c7f1e5f8693bd6f060ab
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL maccha-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 4.4 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
57ff83783ccbe59197f45345841459d8bf6ca05c43a72bcbc00199211f46126b
BLAKE2b-256 checksum
How to use checksums
ff53edd26aa418b1646998852d980470a1ba20d0c7dfd2d858575f56e572b77b
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 Nov 30, 2026.

Transparency log

Release files / maccha-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL maccha-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 4.7 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
676e201db05cc8598c0d03bb9b51bee30c75b1282700b89cb82261eb54884f39
BLAKE2b-256 checksum
How to use checksums
239fe98f9eb0da4d26baf9c6ef065648e68357a7ac82a16cdd477d1113c5a4c2
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 Nov 30, 2026.

Transparency log

Security for maccha 0.1.0

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 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for maccha-0.1.0.tar.gz

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 Nov 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.1.0 This release

7 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