<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ghazali alShafi</title>
    <description>The latest articles on DEV Community by Ghazali alShafi (@_ghazali).</description>
    <link>https://dev.to/_ghazali</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4266084%2F9e5b3e76-c6af-40a7-9152-d419ac37e0df.png</url>
      <title>DEV Community: Ghazali alShafi</title>
      <link>https://dev.to/_ghazali</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_ghazali"/>
    <language>en</language>
    <item>
      <title>nimaid: Render Mermaid diagrams to PNG, GIF, and SVG in Python no dependency ~1.1 MB wheel, zero browser/Node.js dependencies</title>
      <dc:creator>Ghazali alShafi</dc:creator>
      <pubDate>Thu, 26 Nov 2026 06:29:37 +0000</pubDate>
      <link>https://dev.to/_ghazali/nimaid-render-mermaid-diagrams-to-png-gif-and-svg-in-python-no-dependency-11-mb-wheel-zero-44fp</link>
      <guid>https://dev.to/_ghazali/nimaid-render-mermaid-diagrams-to-png-gif-and-svg-in-python-no-dependency-11-mb-wheel-zero-44fp</guid>
      <description>&lt;p&gt;If you've ever tried to render Mermaid diagrams to static images in a Python backend, CI pipeline, or Docker container, you know the pain: you usually end up installing Node.js, mermaid-cli, and a 300+ MB headless Chromium/Playwright binary just to generate a flowchart.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;nimaid&lt;/strong&gt; (&lt;code&gt;pip install nimaid&lt;/code&gt;) to solve this.&lt;br&gt;
It’s a native, zero-dependency Mermaid renderer written from scratch in pure Nim and packaged into prebuilt ~1.1 MB Python wheels.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PyPI: &lt;a href="https://pypi.org/project/nimaid/" rel="noopener noreferrer"&gt;https://pypi.org/project/nimaid/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub : &lt;a href="https://github.com/ghazalialshafi/nimaid" rel="noopener noreferrer"&gt;https://github.com/ghazalialshafi/nimaid&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quick Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import nimaid

# Render directly to PNG bytes
png_bytes = nimaid.png("""
flowchart LR
    A[Markdown / LLM] --&amp;gt; B(nimaid)
    B --&amp;gt; C{Format}
    C --&amp;gt; D[PNG / GIF]
    C --&amp;gt; E[SVG]
""")

with open("diagram.png", "wb") as f:
    f.write(png_bytes)

# Or SVG string with Mermaid themes ("default", "dark", "forest", "neutral", "base")
svg_str = nimaid.svg("sequenceDiagram\n Alice-&amp;gt;&amp;gt;Bob: Hi", theme="dark")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpn7c8kochp6u7gl9x4ob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpn7c8kochp6u7gl9x4ob.png" alt="Output Image" width="799" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key Features :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Completely self-contained&lt;/strong&gt;: No browser, no Node.js, no Cairo, and no system fonts required not even any other python lib. DejaVu Sans is embedded directly in the native binary, so it works immediately after pip install in minimal containers (including Alpine/musllinux).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;18 Diagram&lt;/strong&gt; Types Supported: &lt;strong&gt;&lt;em&gt;flowchart/graph, sequenceDiagram, stateDiagram(-v2), erDiagram, classDiagram, gantt, gitGraph, mindmap, pie, xychart-beta, timeline, quadrantChart, journey, packet, kanban, radar-beta, treemap-beta, and sankey-beta&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jupyter &amp;amp; Pillow Ready&lt;/strong&gt;: &lt;code&gt;nimaid.Diagram(text)&lt;/code&gt; renders inline SVGs automatically as the last expression in a Jupyter cell, and &lt;code&gt;nimaid.rgba(text).to_pil()&lt;/code&gt; hands off straight-alpha pixels to Pillow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Fonts&lt;/strong&gt; &amp;amp; &lt;strong&gt;Color Emoji&lt;/strong&gt;: Pass any TrueType (.ttf) font via &lt;code&gt;nimaid.Context(font="...")&lt;/code&gt;, or run pip install "nimaid[emoji]" for lazy-loaded Noto Color Emoji support.&lt;/li&gt;
&lt;li&gt;Actionable Syntax Errors: &lt;em&gt;Invalid syntax raises nimaid.ParseError (a ValueError subclass) with exact token/position details—useful&lt;/em&gt; if you are validating or auto-repairing LLM-generated Mermaid code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C-api&lt;/strong&gt;: Full supported so it can be used from any language easily, see the &lt;a href="https://github.com/ghazalialshafi/nimaid/releases/tag/v0.6.0" rel="noopener noreferrer"&gt;release section&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Would love any feedback on the Python API, missing Mermaid syntax edge cases, or performance on large diagrams!&lt;br&gt;
Please try it yourself.&lt;/p&gt;

</description>
      <category>python</category>
      <category>devops</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
