Skip to main content

merm

Pure Python Mermaid diagram renderer. Converts Mermaid markup to SVG with zero JavaScript dependencies.

Install

pip install merm

Usage

Command line

# File to file (SVG)
merm diagram.mmd -o diagram.svg

# PNG output
merm diagram.mmd -o diagram.png

# Pipe
echo 'graph LR
    A --> B --> C' | merm > diagram.svg

# With a theme
merm diagram.mmd --theme dark -o diagram.svg

# With uvx (no install needed)
uvx merm diagram.mmd -o diagram.svg

Python API

from merm import render_diagram, render_to_file, render_to_png

# Render to SVG string
svg = render_diagram("""
flowchart TD
    A[Start] --> B{Decision}
    B -->|Yes| C[OK]
    B -->|No| D[End]
""")

# Render directly to file (format auto-detected from extension)
render_to_file("flowchart TD\n    A --> B", "diagram.svg")
render_to_file("flowchart TD\n    A --> B", "diagram.png")

# Render to PNG bytes
png_bytes = render_to_png("flowchart TD\n    A --> B")

# With a theme
svg = render_diagram("flowchart TD\n    A --> B", theme="dark")

Supported diagram types

All examples below are rendered by merm. Browse all 131 rendered examples in docs/examples/.

Flowchart

flowchart LR
    A[Hard] -->|Text| B(Round)
    B --> C{Decision}
    C -->|One| D[Result 1]
    C -->|Two| E[Result 2]
Flowchart

Sequence diagram

sequenceDiagram
    Alice->>John: Hello John, how are you?
    loop HealthCheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts!
    John-->>Alice: Great!
    John->>Bob: How about you?
    Bob-->>John: Jolly good!
Sequence diagram

Class diagram

classDiagram
    Class01 <|-- AveryLongClass : Cool
    Class09 --> C2 : Where am I?
    Class09 --* C3
    Class09 --|> Class07
    Class07 : equals()
    Class07 : Object[] elementData
    Class01 : size()
    Class01 : int chimp
    Class01 : int gorilla
    class Class10 {
        int id
        size()
    }
Class diagram

State diagram

stateDiagram-v2
    [*] --> Still
    Still --> [*]
    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]
State diagram

Entity relationship diagram

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
    CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
ER diagram

Gantt chart

gantt
    section Section
    Completed :done, des1, 2014-01-06, 2014-01-08
    Active :active, des2, 2014-01-07, 3d
    Parallel 1 : des3, after des1, 1d
    Parallel 2 : des4, after des1, 1d
    Parallel 3 : des5, after des3, 1d
    Parallel 4 : des6, after des4, 1d
Gantt chart

Pie chart

pie
    "Dogs" : 386
    "Cats" : 85.9
    "Rats" : 15
Pie chart

Git graph

gitGraph
    commit
    commit
    branch develop
    checkout develop
    commit
    commit
    checkout main
    merge develop
    commit
    commit
Git graph

Mindmap

mindmap
  root((Central Topic))
    Origins
      Long history
      Popularized by Tony Buzan
    Research
      On effectiveness
      On features
    Tools
      Pen and paper
      Mermaid
Mindmap

Flowchart with Font Awesome icons

flowchart TD
    A[fa:fa-tree Christmas Tree] --> B[fa:fa-gift Presents]
    A --> C[fa:fa-star Star on Top]
    B --> D[fa:fa-car Drive to Grandma]
    C --> E[fa:fa-lightbulb Lights]
    D --> F[fa:fa-home Grandma's House]
    E --> F
Christmas tree flowchart

Features

  • Pure Python — no Node.js, no browser, no Puppeteer
  • ~200x faster than mermaid-cli (mmdc)
  • SVG and PNG output
  • 4 built-in themes: default, dark, forest, neutral
  • Theme directives: %%{init: {'theme': 'dark'}}%%
  • 9 diagram types: flowchart, sequence, class, state, ER, gantt, pie, mindmap, gitgraph
  • All flowchart shapes and edge types
  • Subgraph nesting and styling
  • Edge labels and arrow markers
  • Font Awesome icons
  • CLI tool with stdin/stdout piping

Performance

Benchmarked against mermaid-cli (mmdc) across 28 scenarios:

merm mmdc
Average render time ~1 ms ~200 ms
Dependencies 0 Node.js + Puppeteer
Startup overhead None ~500 ms

License

WTFPL

Metadata

Release files for merm 0.1.5

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

Source distribution (sdist)

Source distribution for merm 0.1.5
File Size Uploaded Provenance
merm-0.1.5.tar.gz 823.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for merm 0.1.5
File Interpreter ABI Platform
merm-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 982.9 kB

Release files / merm-0.1.5.tar.gz

Download URL merm-0.1.5.tar.gz
Size 823.6 kB
Tags Source
SHA-256 checksum
How to use checksums
32ec2d1b582621a482295811c35a445072355d13b9f9da6136d63cfd9d3b4cfd
BLAKE2b-256 checksum
How to use checksums
8fe0979fd10d4e24359156aa60d4f994bbcb3ca9475783c5fc689efb81a217c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / merm-0.1.5-py3-none-any.whl

Download URL merm-0.1.5-py3-none-any.whl
Size 159.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4372cd5474a1a42e185a21f9ab19ac9aa24fcab2638f1f0379545d9cc10b1e4a
BLAKE2b-256 checksum
How to use checksums
c96a37843c1e6fd78a2ed4cfc23ae4c09d93417b5c076d30df1be5df5d021fae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for merm 0.1.5

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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