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.1

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.1
File Size Uploaded Provenance Actions
maccha-0.1.1.tar.gz 1.1 MB With provenance Details for maccha-0.1.1.tar.gz

Built distributions (wheels)

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

Total release size: 30.2 MB

Release files / maccha-0.1.1.tar.gz

Download URL maccha-0.1.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
eb4d7cf77026b232549c97a979c2b917932c2448ea866beaa5bf515d981a04ff
BLAKE2b-256 checksum
How to use checksums
e2bc11c4005f1c01a2efb92d148f8a3d98c93c4fb584d3caeb453acdb80881e3
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-cp39-abi3-win_amd64.whl
Size 4.9 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a041ed7a9161e61956b55ec20f57cd4795b1a4dc55896fc54a083facf8125b67
BLAKE2b-256 checksum
How to use checksums
ab6edd559d171a29f5ee82be717ef044d0b8776d5129a8587d0f812d68e6ba5c
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 5.3 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d2ae32b72435676c22d9e6cd969c8d25cc602c4b8c2fc20331fa26f63e39fac0
BLAKE2b-256 checksum
How to use checksums
b604dd6523bb17720dcfcc456bebdcb5e1178366187a93c92c6ef8e28986b9e9
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-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
4b3a06b2ac43b52509ac15ce238c024953b8e1a88b0eba318df3aad0db3d1d56
BLAKE2b-256 checksum
How to use checksums
a4ce1b547d3f9bd47014630d9bf953825b6c4c27498e8fbfbc1edfb937cc9d08
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-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
338f3d0ac7c0fa1aa356559bc3c5d742f6725ed78eec0ececf1e6ec26f4cb71b
BLAKE2b-256 checksum
How to use checksums
23e5966281b2f828bfe1ade1b111144335bb6a662c384935a73c89c5f334ce28
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Size 4.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6457decd6ba1f5d39cfd993a8e0818d8f3dddf7762f76f43faa703942b8a1931
BLAKE2b-256 checksum
How to use checksums
ba9021d58f26b158385603ad1297552eef1101bf07683d7e32fffd7a2d2935fe
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 Dec 1, 2026.

Transparency log

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

Download URL maccha-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 4.8 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
94b9adcf317f4a65953ee98b40ea4cd5a51db6b242a895bc38d8e7ca818e775a
BLAKE2b-256 checksum
How to use checksums
edb9ff61deeea3c696e0f1f956585ad40e035e98a1c755d6b73a14b711345d24
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 Dec 1, 2026.

Transparency log

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

Select from 7 files

Attestation for maccha-0.1.1.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 Dec 1, 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.1 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