Four years ago, I did a video on how to use Mermaid.js with Business Central. That was with rendering of the diagrams in a ControlAddin with JavaScript. This time, I have moved the rendering into AL code, so I’m not dependent on the controladdin. Check the video:

The source code can be found here: https://github.com/hougaard/AL-Mermaid/
In this video, Erik revisits a topic he first covered back in December 2022 — generating diagrams with Mermaid.js inside Business Central using AL code. This time, the approach is fundamentally different and significantly more powerful: instead of relying on the browser to render Mermaid diagrams at runtime, the new 2026 edition renders diagrams server-side in AL, producing SVG output that can be embedded anywhere.
Why Revisit This Topic?
Four years ago, Erik created a solution that used Mermaid.js running in a control add-in — the browser would receive the Mermaid diagram code and render it at runtime. While this worked, it introduced complications: the rendering happened client-side, meaning you had to send Mermaid code to the browser and wait for it to render. If you were already building HTML or generating content in AL, this felt backwards.
The core problem: if you’re generating content in AL and need a diagram embedded in it, you want the diagram rendered before you assemble the final output — not after, when it reaches the browser.
Enter Pele: Server-Side Mermaid Rendering
Erik discovered Pele — not the soccer legend, but a library named after Pele, the Hawaiian goddess of volcanoes and fire. Pele is a lightweight, open-source, MIT-licensed library that renders Mermaid diagrams directly to SVG without needing a browser environment.
The key insight was: if Pele is truly lightweight, could it run inside AL code in Business Central? The answer turned out to be yes. With the help of modern BC capabilities, Erik and collaborators ported the rendering logic so that AL code can now:
- Accept Mermaid diagram syntax as input
- Render the diagram to SVG entirely in AL
- Embed the resulting SVG wherever it’s needed
The App Structure
The open-source app consists of a set of codeunits that handle the rendering, along with tests and a playground page for experimentation. The playground includes a preview control add-in so you can see the rendered diagrams directly in Business Central.
Supported Diagram Types
Erik demonstrated a wide variety of Mermaid diagram types, all rendering successfully within Business Central:
- Flowcharts — including the classic “Christmas shopping” example
- Sequence diagrams — for visualizing interactions between systems or actors
- Entity relationship diagrams
- State diagrams (version 2)
- Gantt charts — with clickable elements and callback support
- Pie charts
- Git graphs — branch/release flow visualizations
- Mind maps
- Timelines
- Journey diagrams
Performance
One of the most impressive aspects is the rendering speed. Even complex diagrams render in just 4-5 milliseconds within AL code. Erik emphasized why this matters: the hard part of diagram rendering isn’t drawing the shapes — it’s the layout algorithm that figures out where to position elements, spacing them correctly. This is a well-known hard computing problem, and the fact that it executes this quickly in AL is remarkable.
Interactive Click Events
The rendered diagrams support interactivity. Elements can be configured as clickable, and when a user clicks on a diagram node, an event fires back to AL code with callback information. This opens up powerful UX possibilities:
- Configure which elements are clickable vs. display-only
- Receive callback identifiers (e.g., “open customer”, “job 001”) when elements are clicked
- Use diagrams as actual navigation UI within Business Central
For example, in the Gantt chart demo, only specific elements like “back end” were clickable, while others were purely informational. The click callback passes back an identifier like open job 001, which your AL code can handle however you choose.
The Original Approach (2022 Edition)
For reference, the original approach used a control add-in that loaded Mermaid.js in the browser. The add-in definition looked like this:
controladdin testaddin
{
StartupScript = 'startup.js';
Scripts = 'script.js', 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.3.0/mermaid.min.js';
HorizontalStretch = true;
VerticalStretch = true;
event ImAmReady(Parameters: JsonObject);
procedure HeresSomeData(Data: JsonObject);
procedure Draw(code: Text);
}
And the JavaScript rendering function relied on Mermaid’s browser-based API:
function Draw(code) {
try {
const insertSvg = function (svgCode, bindFunctions) {
document.getElementById('controlAddIn').innerHTML = svgCode;
};
mermaid.mermaidAPI.render('chart', code, insertSvg);
}
catch (e) {
console.log(e);
}
}
This approach worked but required the browser to do the heavy lifting. The new approach eliminates this dependency entirely for the rendering step.
Why This Matters
The shift from browser-side to AL-side rendering changes the workflow significantly:
- Embed diagrams in HTML you’re already generating in AL — no need to inject Mermaid.js and wait for browser rendering
- Format and position diagrams correctly before sending them to be displayed
- Use diagrams as proper UI/UX elements inside Business Central, complete with click interactions
- No external JavaScript library dependency at render time
- CSS theming support — including dark mode
Conclusion
This 2026 edition of Mermaid diagram generation in Business Central represents a significant evolution. By bringing the rendering into AL code itself, Erik has eliminated the architectural awkwardness of the original browser-dependent approach. The solution is open-source, performant (single-digit millisecond rendering times), supports a wide range of diagram types, and includes interactive click event handling. The repository link is available in the video description for anyone who wants to try it out — or try to break it. As Erik put it: “If you can dream it, you can probably build it somehow.”