Docs & Code Guide

Embed diagrams in Wiki.js: what renders by default and what the sanitizer strips

Wiki.js gives you two embed routes with very different friction. An image by URL renders out of the box in any Markdown page and stays live, updating within minutes of a diagram edit. An iframe has to survive the html-security module, which sanitizes rendered HTML by default, and relaxing that is an instance-wide admin decision. Here is exactly which setting controls what, and how to choose between the two routes honestly.

7 min readFor teams running a self-hosted Wiki.js instance

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

179/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Image by URL: the route that needs no admin

Standard Markdown image syntax with an absolute URL renders in Wiki.js without touching a single setting. The image is fetched from the source by each reader, not copied into wiki storage, so it keeps tracking the source.

Point it at a Datadef project shared public and the wiki page shows the current diagram: the image is served with an ETag from the diagram's last edit and a five minute cache lifetime, so an edit shows up within minutes. No page save, no re-upload, no asset manager involvement.

![Platform architecture](https://datadef.io/api/embed/my-platform-a1b2c3d4)

<!-- Sized render for wide pages (params optional) -->
![Platform architecture](https://datadef.io/api/embed/my-platform-a1b2c3d4?width=2400&height=1400&scale=2)

Iframes and the html-security module

Rendered content in Wiki.js flows through a rendering pipeline of modules, and the one that decides an iframe embed is html-security, which sanitizes the final HTML with DOMPurify. With its Sanitize HTML option enabled, the default, iframes are stripped from the output. The switch lives in the admin area under Rendering, in the HTML section, under Security.

Turning Sanitize HTML off is an instance-wide decision, not a per-page one, and it is exactly what it sounds like: every editor on the wiki can then inject arbitrary HTML into pages. On a wiki where every editor is trusted, that may be acceptable. On anything larger, leave the sanitizer on and use the image form, which needs no exemption and carries the same freshness.

<!-- Renders only if Sanitize HTML is disabled in
     Administration > Rendering > HTML > Security -->
<iframe
  src="https://datadef.io/embed/my-platform-a1b2c3d4"
  style="width: 100%; height: 480px; border: none;"
  title="Platform architecture"
></iframe>

The honest tradeoff

Disabling sanitization buys pan and zoom inside the wiki at the cost of trusting every editor with raw HTML. If that trade feels wrong, the image URL form delivers the same live diagram with the sanitizer left on.

Markdown editor versus the visual editor

Wiki.js offers multiple editors per page, and the two common ones handle embeds differently. The Markdown editor is the direct route: paste the image syntax or, where allowed, the iframe tag, and the preview shows the result. The visual editor works through dialogs; inserting an image by URL means using its image dialog rather than typing syntax.

For pages that carry architecture diagrams, the Markdown editor is the safer habit: the embed is visible as plain text in the page source, survives editor switches, and diffs cleanly in page history when someone changes the URL.

Keeping the diagram current behind the wiki

The wiki now shows whatever the diagram is; keeping the diagram true to the system is the remaining work, and it never touches Wiki.js. An agent hooked to the Datadef MCP server, registry name io.datadef/mcp, can make that edit from the repository, redrawing the diagram after a merge that touched the services it covers, and every wiki page holding the embed follows. To be plain about the mechanics, Datadef never polls repositories and detects nothing by itself; the agent runs when your pipeline or your team starts it, authenticated with an API key from a paid plan.

The wider habit of keeping wiki content aligned with reality, beyond diagrams, is covered in keeping the internal wiki in sync.

Limits, stated plainly

The embed URLs exist only for projects shared public. A self-hosted Wiki.js instance often exists precisely because content must stay inside the network, and for confidential architectures the honest answer is an uploaded static export, refreshed when the system changes, staleness accepted.

Wiki.js also ships a diagrams integration of its own via draw.io style editing, and for one-off drawings owned by a single page it is perfectly serviceable. The difference is what happens after the drawing: an embedded, source-backed diagram can be regenerated by an agent when the code changes, while a hand drawing waits for a human to remember it. The Markdown baseline for READMEs and repos is covered in embed diagrams in Markdown.

FAQ

How do I embed an external image in Wiki.js?

Use standard Markdown image syntax with the absolute URL in any Markdown page. No admin setting is involved; the image renders immediately and is fetched from the source by each reader, so it stays current with the source.

Why is my iframe stripped in Wiki.js?

The html-security rendering module sanitizes final HTML with DOMPurify, and with Sanitize HTML enabled, the default, iframes are removed. The toggle is in Administration under Rendering, HTML section, Security. Disabling it applies to the whole instance, so weigh it against how much you trust every editor.

Is it safe to disable Sanitize HTML in Wiki.js?

Only if every editor on the instance is trusted, because the setting is instance-wide and allows arbitrary HTML in pages. On larger wikis, keep the sanitizer on and embed diagrams as images by URL instead, which needs no exemption.

Does an embedded diagram update automatically in Wiki.js?

The wiki page shows the current image whenever it is viewed, because the image is hotlinked from the source rather than copied into wiki storage. Datadef serves it with a five minute cache lifetime, so an edited diagram appears within minutes. The diagram edit itself is done by a person or an MCP-connected agent, not detected automatically.

Should I use the Wiki.js draw.io integration or an embedded diagram?

Use the built-in drawing tools for one-off sketches owned by a single page. Use a live embed when the diagram represents a system that changes, because the source diagram can be updated once, by hand or by an agent reading the repository, and every page embedding it follows.