Mermaid, Graphviz & Chart to PNG, SVG or PDF avatar

Mermaid, Graphviz & Chart to PNG, SVG or PDF

Pricing

$3.00 / 1,000 diagram or chart rendereds

Go to Apify Store
Mermaid, Graphviz & Chart to PNG, SVG or PDF

Mermaid, Graphviz & Chart to PNG, SVG or PDF

Render Mermaid, Graphviz DOT, Vega-Lite, Vega, Chart.js or SVG code to a PNG, SVG or PDF link for AI agents and MCP. Bad code returns the exact error with line number so the agent can fix and retry. $0.003 per diagram, errors free.

Pricing

$3.00 / 1,000 diagram or chart rendereds

Rating

0.0

(0)

Developer

FFS Marketing

FFS Marketing

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

2 hours ago

Last modified

Features

Limited permissions

Share

Turn diagram or chart code into an image file your agent can share. Send Mermaid (flowchart, sequence, class, ER, gantt, pie, mindmap, timeline and more), Graphviz DOT, a Vega-Lite or Vega spec, a Chart.js config or raw SVG, and get back a PNG, SVG or PDF as a public link. When the code is wrong you get the parser's exact error, the line number and the offending line, so the agent can fix it and call again.

Works as a tool for AI agents. Add it to Claude, ChatGPT, Cursor, VS Code or any MCP client through Apify's MCP server (https://mcp.apify.com/?tools=fluidfaith/mermaid-chart-renderer), or call it with one API request. JSON in, JSON out. Setup is in Use it from an agent.

Costs $0.003 per diagram rendered. Code with errors is free, and your maximum charge per run is never exceeded.

Why use it

  • Agents write diagram code all day but cannot show it. Slack, email, n8n, chat replies, Google Docs and PDFs need an image, and most agents have no headless browser to run mermaid-cli.
  • Errors an LLM can act on. Parse error on line 3, the text of line 3 and a short fix hint come back as fields, not a stack trace. Errors are not charged, so retrying is free until it renders.
  • Six languages in one tool. Mermaid, Graphviz (8 layout engines), Vega-Lite, Vega, Chart.js and SVG. Leave type empty and it is detected from the code.
  • PNG, SVG or PDF. PNG at 2x for sharp phone and retina screens, SVG as a file and inline markup, PDF sized to the diagram for print.
  • Themes. Mermaid default, dark, neutral and forest; dark also gives charts light text on a dark background. Any background color, or transparent.
  • Offline and safe. Rendering never touches the network, scripts in SVG are stripped, Mermaid runs in strict mode.

What you get

FieldWhat it is
statusOK (rendered and charged) or ERROR (not charged).
fileUrlPublic link to the PNG, SVG or PDF.
type, formatWhat was rendered (mermaid, graphviz, vegalite, vega, chartjs, svg) and the output format.
width, heightSize of the diagram in CSS pixels.
pixelWidth, pixelHeightSize of the PNG (width x scale).
svgWith SVG output: the SVG markup itself (under 100 KB), ready to embed.
errorThe parser's message, for example Parse error on line 3: ... Expecting 'SQE', got 'PS'.
errorLine, errorColumnWhere the error is, when the parser says.
errorExcerptThe text of that line.
hintOne line on what usually fixes this kind of error.
warningsFor example outside images that were not loaded.

The run summary in the OUTPUT record has status (OK, PARTIAL, ERROR), counts, and a short list of every diagram with its link or error.

Input

One diagram:

{
"code": "flowchart LR\n A[Agent writes Mermaid] --> B{Valid?}\n B -- yes --> C[PNG link]\n B -- no --> D[Error with line number]",
"format": "png"
}

Many diagrams in one run (each one billed only if it renders):

{
"diagrams": [
{ "name": "deploy-flow", "code": "digraph { rankdir=LR; build -> test -> deploy }" },
{ "name": "weekly-runs", "type": "chartjs", "code": { "type": "bar", "data": { "labels": ["Mon", "Tue"], "datasets": [{ "label": "Runs", "data": [12, 19] }] } } },
{ "name": "arch", "sourceUrl": "https://github.com/owner/repo/blob/main/docs/architecture.mmd", "format": "svg" }
],
"theme": "dark"
}
FieldDefaultWhat it does
codeThe code of one diagram as text (up to 200,000 characters). Inside diagrams, Vega-Lite, Vega and Chart.js specs can also be JSON objects.
typedetectedmermaid, graphviz, vegalite, vega, chartjs or svg. Detection: <svg is SVG, digraph/graph is Graphviz, JSON with a vega-lite $schema is Vega-Lite, JSON with type + data.datasets is Chart.js, anything else is Mermaid.
diagramsUp to 100 { code, type, name, format, theme, background, engine, sourceUrl } objects.
sourceUrlFetch the code from a public link instead: a raw file, a GitHub file page or a gist (up to 1 MB).
formatpngpng, svg or pdf. Chart.js gives PNG or PDF.
themedefaultdefault, dark, neutral, forest.
backgroundwhiteAny CSS color, or transparent. Dark theme defaults to #1e1e1e.
scale2PNG pixel density, 1 to 4.
width, height800, 500Chart.js canvas size.
graphvizEnginedotdot, neato, fdp, sfdp, circo, twopi, osage, patchwork.
includeSvgTexttruePut the SVG markup in the result row too.
timeoutSecsPerDiagram20A diagram that takes longer becomes an ERROR row (free).
maxConcurrency2Diagrams rendered at the same time (1 to 4).

Output

{
"name": "diagram-1",
"type": "mermaid",
"format": "png",
"status": "OK",
"fileUrl": "https://api.apify.com/v2/key-value-stores/.../records/diagram-1-e15b79.png",
"width": 636, "height": 210, "pixelWidth": 1272, "pixelHeight": 420,
"bytes": 32831, "error": null, "warnings": []
}

And when the code is wrong (not charged):

{
"name": "diagram-1",
"type": "mermaid",
"status": "ERROR",
"fileUrl": null,
"error": "Parse error on line 3:\n...B -->> C[[Oops\n----------------------^\nExpecting ...",
"errorLine": 3,
"errorExcerpt": " B -->> C[[Oops",
"hint": "Check the diagram keyword on the first line (flowchart TD, sequenceDiagram, ...) and the arrow syntax near the line shown."
}

Use it from an agent

Through Apify's MCP server (Claude, ChatGPT, Cursor, VS Code, any MCP client)

{
"mcpServers": {
"diagram-renderer": {
"url": "https://mcp.apify.com/?tools=fluidfaith/mermaid-chart-renderer",
"headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
}
}
}

Claude Code: claude mcp add --transport http diagram-renderer "https://mcp.apify.com/?tools=fluidfaith/mermaid-chart-renderer" --header "Authorization: Bearer $APIFY_TOKEN". Or over stdio: npx -y @apify/actors-mcp-server --tools fluidfaith/mermaid-chart-renderer with APIFY_TOKEN set.

A good instruction for agents: "When a diagram or chart would help, write it as Mermaid (or Vega-Lite for data), call mermaid-chart-renderer, and share fileUrl. If status is ERROR, fix the line in errorLine and call again."

Through the API (one call, waits for the result)

curl -s -X POST "https://api.apify.com/v2/acts/fluidfaith~mermaid-chart-renderer/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"code":"sequenceDiagram\n User->>Agent: question\n Agent-->>User: diagram"}'

From JavaScript

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('fluidfaith/mermaid-chart-renderer').call({ code: 'pie title Pets\n "Dogs" : 386\n "Cats" : 85' });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].status === 'OK' ? items[0].fileUrl : `${items[0].errorLine}: ${items[0].error}`);

Pricing

Pay per event: $0.003 per diagram rendered. That is it: no start fee, nothing for errors, refused links or diagrams that hit the time limit. 100 diagrams cost $0.30. Set a maximum charge per run and the Actor stops before it, never after; the summary then shows stoppedAtSpendingCap: true and how many were not rendered.

Safety

  • Rendering is offline: the browser that draws the diagram cannot reach any network address, so code that points at outside images, data or internal addresses loads nothing. Vega-Lite specs that need outside data get a clear error instead of an empty chart.
  • SVG input and every SVG output are cleaned: no scripts, no event handlers, no javascript: links, no embedded HTML.
  • Mermaid runs with securityLevel: strict (no click handlers or HTML labels).
  • sourceUrl only fetches public addresses: localhost, private networks, link-local and cloud metadata addresses are refused, including through redirects and DNS.

Privacy

Your code and the files it produces stay in your own Apify run storage. Nothing is sent anywhere else, and no personal data is collected.

FAQ

Which Mermaid diagrams work? Mermaid 12: flowchart, sequence, class, state, ER, gantt, pie, mindmap, timeline, journey, git graph, quadrant, sankey, XY chart, block, packet, kanban, architecture and more.

Why did my Mermaid fail with "got 'participant_actor'"? Actor is a Mermaid keyword in sequence diagrams. Rename the participant (for example Renderer). Errors like this are free; fix and retry.

Can I use data from a URL in Vega-Lite? Not inside the spec (rendering is offline). Put the rows under data.values, or fetch the whole spec with sourceUrl.

How long are the files kept? In your run's key-value store, for as long as your Apify plan keeps run storage (named storages keep them forever).

Can I get a transparent PNG? Yes: "background": "transparent".

Other Actors by Fluid Faith

Load them together as MCP tools: https://mcp.apify.com/?tools=fluidfaith/mermaid-chart-renderer,fluidfaith/visual-diff-gate,fluidfaith/mobile-qa-gate,fluidfaith/lighthouse-gate,fluidfaith/pdf-to-markdown-tables,fluidfaith/media-probe