Skip to main content

MkDocs Plugin for embedding Drawio files

Image

Publish Badge PyPI PyPI - Downloads

See the official docs and the live example page.

Features

This plugin enables you to embed interactive drawio diagrams in your documentation. Simply add your diagrams like you would any other image:

You can either use diagrams hosted within your own docs. Absolute as well as relative paths are allowed:

Absolute path:
![](/assets/my-diagram.drawio)

Same directory as the markdown file:
![](my-diagram.drawio)

Relative directory to the markdown file:
![](../my-diagram.drawio)


Or you can use external urls:
![](https://example.com/diagram.drawio)

Additionally this plugin supports multi page diagrams by using either the page or alt property. To use the page property, you need to use the markdown extension attr_list.

Either use the alt text:
![Page-2](my-diagram.drawio)
![my-custom-page-name](my-diagram.drawio)

Or use the page attribute:
![Foo Diagram](my-diagram.drawio){ page="Page-2" }
![Bar Diagram](my-diagram.drawio){ page="my-custom-page-name" }

Setup

Install the plugin with pip:

pip install mkdocs-drawio

If you are managing your MkDocs project with uv, use:

uv add mkdocs-drawio

Add the plugin to your mkdocs.yml

plugins:
  - drawio

Configuration Options

Full documentation of the configuration options and examples can be found in the official documentation

By default the plugin uses the official url for the minified drawio javascript library. To use a custom source for the drawio viewer you can overwritte the url. This might be useful in airlocked environments.

If you want to use a self-hosted JavaScript viewer file. You should download the latest version from the official drawio repo.

Self-hosted viewer paths can be configured as site-root paths such as js/viewer-static.min.js. The plugin normalizes them per page, so they also work on versioned deployments such as mike.

plugins:
  - drawio:
      viewer_js: "https://viewer.diagrams.net/js/viewer-static.min.js"

Further options are:

plugins:
  - drawio:
      tooltips: true       # Enable tooltips on diagram elements
      border: 5            # Border size / padding around diagrams
      edit: true           # Enable opening the editor for diagrams
      darkmode: true       # Enable dark mode support (classic MkDocs and Material)
      highlight: "#0000FF" # Highlight color for hyperlinks
      lightbox: true       # Enable opening the lightbox on click
      toolbar:             # Control the looks and behaviour of the toolbar
        pages: true        # Display the page selector
        tags: true         # Display the tags selector
        zoom: true         # Display the zoom controls
        layers: true       # Display the layer controls
        lightbox: true     # Display the lightbox / fullscreen button
        position: "top"    # Control the position of the toolbar (top or bottom)
        no_hide: false     # Do not hide the toolbar when not hovering over diagrams
        show_title: false  # Show the diagram title in the toolbar based on the file name

Material Integration

If you are using the Material Theme and want to use the instant-loading feature. You will have to configure the following:

In your mkdocs.yaml:

theme:
  name: material
  features:
    - navigation.instant

plugins:
  - drawio

extra_javascript:
  - https://viewer.diagrams.net/js/viewer-static.min.js
  - javascripts/drawio-reload.js

Add docs/javascripts/drawio-reload.js to your project:

document$.subscribe(({ body }) => {
  // if drawio toolbar icons/buttons are not showing or missing due to title being longer than the image width
  // you can set a minimum width for the graph viewer by uncommenting the following line
  // GraphViewer.prototype.minWidth = 500;

  GraphViewer.processElements()

  // required to fix duplicate display of external drawio graphs (via http)
  reload();
})

Using Tabs (pymdownx.tabbed)

If you want to use drawio diagrams inside of tabs you need to make sure that the diagrams are processed after the tabs are rendered. You can achieve this by adding the following javascript to your mkdocs.yml:

extra_javascript:
  - javascripts/drawio-tabs.js

Add docs/javascripts/drawio-tabs.js to your project:

document.addEventListener('change', (event) => {
  // Check if the target is a pymdownx tab input
  if (event.target.matches('.tabbed-set > input')) {
    GraphViewer.processElements()
  }
});

Its a bit of a workaround as it listens for all events on the page and retriggers the drawio processing if any tab is clicked.

How it works

  1. mkdocs generates the html per page
  2. mkdocs-drawio attaches to the on_post_page event. For more details, please have a look at the event lifecycle documentation
  3. Adds the drawio viewer library
  4. Searches through the generated html for all img tags that have a source of type .drawio
  5. Replaces the found img tags with mxgraph html blocks (actual drawio diagram content). For more details, please have a look at the official drawio.com documentation.

Contribution guide

  1. Install uv and use Python 3.9 or newer.
  2. Install dependencies and the current project: uv sync --group dev
  3. Make your desired changes.
  4. Add a test for your changes in the examples directory.
  5. Test your changes with uv run mkdocs serve -f examples/mkdocs.yml
  6. Increase the version in pyproject.toml.
  7. Make sure uv run ruff check . and uv run black --check . pass.
  8. Open your pull request ✨️

Project History

Sergey (onixpro) is the original creator of this plugin but since his repository isn't maintained anymore we forked it on the 19th December of 2023 and have been keeping it up-to-date and expanding on the features since then. Buy Sergey a ☕

Metadata

Release files for mkdocs-drawio 1.16.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-drawio 1.16.3
File Size Uploaded
mkdocs_drawio-1.16.3.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-drawio 1.16.3
File Interpreter ABI Platform
mkdocs_drawio-1.16.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / mkdocs_drawio-1.16.3.tar.gz

Download URL mkdocs_drawio-1.16.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b69eac62b81810c9bb9c1a005c4cab7b39508a5821d77c65d7714aaa3dfbb3bd
BLAKE2b-256 checksum
How to use checksums
621f6d41a23a7129b93e9a0b332ebf3f6725f0f13f851bfd9a08f031ec88e042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / mkdocs_drawio-1.16.3-py3-none-any.whl

Download URL mkdocs_drawio-1.16.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afd73d0e0dd3bfd91af8dd68becb9be694d8483e915b0aec34c26ea82b567acb
BLAKE2b-256 checksum
How to use checksums
8da368e1e7999f794cdee328b3738895ea3ffd427e964b8234d27fb6bd9afcb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.16.3 This release

2 release files

1.16.2

2 release files

1.16.1

2 release files

1.16.0

2 release files

1.15.0

2 release files

1.14.0

2 release files

1.12.2

2 release files

1.12.1

2 release files

1.12.0

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.11.0

2 release files

1.10.0

1 release file

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.5

2 release files

1.5.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page