Pele: dependency-free synchronous Mermaid-to-SVG renderer

catalog · https://github.com/obsidianmd/pele · by Obsidian (obsidianmd org, kepano) · Evaluated 10 October 2026
mermaiddiagramssvgrenderingstatic-sitesmarkdownsecurity

What it proposes

Pele is a TypeScript library that turns Mermaid diagram source into SVG. It has no dependencies, needs no DOM or headless browser, and runs synchronously. render(text) returns { svg }. In the browser, mount(el, text) renders into an element, reads fonts from CSS and fits the layout to the container width. supports(text) checks whether a diagram type is available. Any failure throws a PeleError.

It supports every diagram type built into Mermaid 12.1.0. Each parser runs Mermaid’s own parser specs and is fuzzed against Mermaid’s parser. Layout and visual style are Pele’s own, so the output is not pixel-identical to Mermaid. You can shrink the bundle by registering diagram types one at a time from pele/core, or by loading them on demand through renderAsync.

Theming uses CSS variables (background, foreground, lines, surfaces, accent, font, radius, and eight chart series colours). Theme changes apply without re-rendering.

Security is a stated design goal. The output SVG never contains scripts, event handlers, <style>, <foreignObject> or HTML. Text is escaped, and inline styles are limited to a fixed list of properties. Mermaid’s click callbacks are ignored. Links and images are restricted to an allowlist of URL schemes, with javascript:, data: and vbscript: always refused. There are size limits on the source, the output and flowchart edge counts. The security notes are honest about what the host app must still do:

  • show error messages as text;
  • trust the icon resolver;
  • block remote image loads if needed;
  • run the render in a worker it can terminate when limits are raised for untrusted input, since render() has no time limit.

Best used when

  • A static site generator or build step renders markdown that contains Mermaid blocks, and you want SVG produced at build time without pulling Chromium in through mermaid-cli or Puppeteer.
  • A Node CLI or report generator has to embed diagrams in HTML output synchronously, with no browser runtime.
  • A web app renders Mermaid from untrusted or user-supplied markdown and wants the output sanitised by design, without bolting an SVG sanitiser onto mermaid.js.
  • The site has its own design system and wants diagrams to follow CSS variables, including light and dark mode, rather than Mermaid’s built-in themes.

Poor fit when

  • Diagrams are only ever viewed inside an editor that already renders Mermaid natively. Adding a renderer there solves nothing.
  • Output must match Mermaid pixel for pixel, for example when diagrams are checked against screenshots from Mermaid-based tools. Pele’s layout is its own.
  • You need Mermaid features beyond 12.1.0 syntax, or interactive click callbacks, which Pele deliberately drops.
  • Stability matters more than footprint. The project is days old and shipped three releases in three days. Its API, layout output and security limits may still change, so pin the version and recheck rendered diagrams after upgrades.
  • No publishing surface needs diagrams at all. In that case it is only worth knowing about.

Verdict

catalog. Pele fills a real gap: rendering Mermaid outside a browser has usually meant either mermaid.js with a DOM or a headless Chromium through mermaid-cli, and a small, synchronous, dependency-free renderer with sanitised output and CSS-variable theming is the better fit for static-site builds and CLI tooling. It comes from the Obsidian team and borrows Mermaid’s own parser specs, which raises confidence in its syntax compatibility. It stays out of active adoption for two reasons: a vault-centred workflow whose editor already renders Mermaid natively has no need for it until a build pipeline or CLI starts publishing diagrams to HTML, and the project is under a week old and still releasing rapidly. Reach for it when that need first appears, pin the version, and keep the default security limits for any input you did not write yourself.