DiagEZ

API

Render Mermaid diagrams from deterministic, embeddable URLs under /r.
Use SVG for the fastest loading speed and unlimited zoom sharpness; use PNG only when a raster image is required.

Endpoint

Use GET with a Base64URL payload.

GET /r/:payload.svg
GET /r/:payload.png
GET /r/:payload

Extensionless URLs redirect to SVG.

Encoding

Encode UTF-8 Mermaid source with Base64URL. Use - and _ instead of + and /, and omit padding.

const source = `graph LR
  Mermaid --> DiagEZ
  DiagEZ --> SVG
  DiagEZ --> PNG`;

const payload = Buffer.from(source, "utf8").toString("base64url");
const url = `https://diagez.com/r/${payload}.svg?theme=github-light`;

Examples

https://diagez.com/r/Z3JhcGggTFIKICBNZXJtYWlkIC0tPiBEaWFnRVoKICBEaWFnRVogLS0-IFNWRwogIERpYWdFWiAtLT4gUE5H.svg?theme=github-light

https://diagez.com/r/Z3JhcGggTFIKICBNZXJtYWlkIC0tPiBEaWFnRVoKICBEaWFnRVogLS0-IFNWRwogIERpYWdFWiAtLT4gUE5H.png?theme=github-light&bg=white&w=900&scale=2

Query Options

themedefault, hand-drawn, cyberpunk, mono, github-light, github-dark
bgtransparent, white, or six-character RGB hex
wOutput width from 128 to 2400 pixels
hOutput height from 128 to 2400 pixels
scaleRaster scale: 1, 2, or 3
padPadding from 0 to 96 pixels

Cache Behavior

The complete URL is the cache key. Keep URLs deterministic and avoid adding irrelevant query parameters. Successful image responses are served with long-lived immutable cache headers.

Cache-Control: public, max-age=31536000, immutable, stale-while-revalidate=604800

Limits and Errors

400Invalid payload, unsupported diagram type, or invalid query parameter
403Cloudflare rejected a malformed or oversized request before Worker handling
413Decoded Mermaid payload is too large
422Mermaid syntax could not be parsed
429Cache-miss rendering is temporarily throttled
503Renderer capacity is temporarily unavailable