mermaiden
mermaiden generates deterministic Mermaid source from typed Python diagram models. It supports the Mermaid syntax families registered by the package and validates each diagram before rendering its text.
The package produces Mermaid text only. Render it with Mermaid in a browser, Markdown viewer, or your own CLI workflow.
Installation
Python 3.12 or later is required.
pip install mermaiden
Quick start
from mermaiden.application import Application
application = Application.create()
diagrams = application.available_diagrams()
print(diagrams)
Application.available_diagrams() returns the supported diagram catalog. Application.diagram_info(diagram_id) returns the typed diagram API for an individual syntax. CLI workflows are available through python -m mermaiden.cli.
Application API
Application is the boundary for API and persistence adapters. Create a diagram by Mermaid syntax id, apply a named domain command, and persist the JSON-safe snapshot returned by the application.
from mermaiden.application import Application, DiagramCommand
application = Application.create()
diagram = application.create_diagram("sequenceDiagram")
application.apply(diagram, DiagramCommand("add_participant", {"id": "api", "label": "API"}))
payload = application.snapshot(diagram).to_dict()
restored = application.restore(payload)
source = application.render(restored)
Snapshots have a versioned envelope and may be stored as JSON. Application.restore() validates restored state before returning it. Command argument values use the diagram operation names; JSON string values are accepted for enum arguments.
The caller can discover the REST contract without maintaining a manifest. diagram_description() returns JSON Schema for the diagram's elements, relations, annotations, and commands. command_payload() returns the generated Pydantic request model for one command.
description = application.diagram_description("sequenceDiagram")
payload_type = application.command_payload("sequenceDiagram", "add_participant")
payload = payload_type.model_validate({"id": "api", "kind": "control"})
Development
The repository uses a single host-mode CI target:
make ci
It installs the development dependencies, runs linting, type checks, tests, compatibility validation, Mermaid CLI rendering, and wheel validation. To open the locally generated diagram preview, run:
make diagrams-test
Release
Releases are versioned by annotated vX.Y.Z tags. After make ci passes, create and push the tag, then publish the GitHub release:
git tag -a v2.0.0 -m "v2.0.0"
git push origin v2.0.0
gh release create v2.0.0 --verify-tag --generate-notes --title v2.0.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mermaiden-5.0.0.tar.gz.
File metadata
- Download URL: mermaiden-5.0.0.tar.gz
- Upload date:
- Size: 94.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6deab55e443c3c7c86f276247801218dfe8364404e713d90932484072d260799
|
|
| MD5 |
28dede136e2a93e21638ef4cb31e4676
|
|
| BLAKE2b-256 |
2ef00fbc3b40110c437ce71507cf2af8678db94e2633cd3cb9d4ba176b57884e
|
Provenance
The following attestation bundles were made for mermaiden-5.0.0.tar.gz:
Publisher:
release.yml on szpak-dev/mermaiden
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mermaiden-5.0.0.tar.gz -
Subject digest:
6deab55e443c3c7c86f276247801218dfe8364404e713d90932484072d260799 - Sigstore transparency entry: 2604329226
- Sigstore integration time:
-
Permalink:
szpak-dev/mermaiden@473426a9b41b68bbfcc38d7c30fcea5ea7f40975 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/szpak-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@473426a9b41b68bbfcc38d7c30fcea5ea7f40975 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mermaiden-5.0.0-py3-none-any.whl.
File metadata
- Download URL: mermaiden-5.0.0-py3-none-any.whl
- Upload date:
- Size: 198.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371b075df8b148ca93aa7ceb9e63706820d31279342299e048550d36349e281a
|
|
| MD5 |
60590b9690aa30ede47a3384c383e291
|
|
| BLAKE2b-256 |
773a43deb96b8f4383413eb1cdf42208eb0f8dea295cad932f2dbd92fade8035
|
Provenance
The following attestation bundles were made for mermaiden-5.0.0-py3-none-any.whl:
Publisher:
release.yml on szpak-dev/mermaiden
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mermaiden-5.0.0-py3-none-any.whl -
Subject digest:
371b075df8b148ca93aa7ceb9e63706820d31279342299e048550d36349e281a - Sigstore transparency entry: 2604329231
- Sigstore integration time:
-
Permalink:
szpak-dev/mermaiden@473426a9b41b68bbfcc38d7c30fcea5ea7f40975 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/szpak-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@473426a9b41b68bbfcc38d7c30fcea5ea7f40975 -
Trigger Event:
release
-
Statement type: