Open source · Swift package

Mermaid diagrams,
drawn in pure Swift.

A Mermaid renderer for Apple platforms with no JavaScript engine, no WKWebView, and no network entitlement — for sandboxed apps that need Markdown previews with diagrams. It's what powers MaiD.

No JS engineCore Graphics & Core Text
No web viewNo WKWebView
Sandbox-safeNo network entitlement
MermaidView.swift
// render — no web view
let view = MermaidView(
  source: """
  graph TD
    A[Parse] --> B[Layout]
    B --> C[Draw]
  """
)
Parse Layout Draw
Why pure Swift

The diagram library for apps that can't — or won't — ship a browser.

Most Mermaid renderers run JavaScript inside a web view. That's a non-starter for a sandboxed app with no network entitlement. swift-mermaid takes a different path.

No JavaScript engine

Parsing, layout, and drawing happen in Swift with Core Graphics and Core Text — no JS runtime to bundle, sandbox, or wait on.

No WKWebView

Nothing to instantiate, no HTML bridge, no async page loads. You get a native view you can drop straight into SwiftUI or AppKit.

🔒

No network entitlement

It never reaches the internet, so it's safe inside the App Sandbox. Your reviewers — and your users — stay happy.

Diagram types

Flowcharts, sequence diagrams, pie charts, and architecture diagrams — the same set MaiD renders in its live preview.

Get started

Add the package, render a view.

swift-mermaid is distributed with Swift Package Manager. Two steps and you're drawing diagrams.

// 1 · add to your Package.swift dependencies
.package(
  url: "https://github.com/australware/swift-mermaid",
  from: "1.0.0"
),

// 2 · render a diagram — no web view, no network
import SwiftMermaid

let view = MermaidView(source: "graph LR; A --> B --> C")
The details

License & platforms.

License
Open source
Free to use in your own apps. See the repository for the license terms.
Platforms
Apple platforms
Built on Core Graphics & Core Text — works wherever they do.
Dependencies
None to speak of
No JS engine, no web view, no network. Just Swift.
Open source

Read the code. Open an issue. Ship a diagram.

swift-mermaid lives on GitHub. Stars, issues, and pull requests are all welcome.