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/:payloadExtensionless 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=2Query Options
themedefault, hand-drawn, cyberpunk, mono, github-light, github-darkbgtransparent, white, or six-character RGB hexwOutput width from 128 to 2400 pixelshOutput height from 128 to 2400 pixelsscaleRaster scale: 1, 2, or 3padPadding from 0 to 96 pixelsCache 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=604800Limits 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
