Skip to main content

drawio2tikz

drawio2tikz is a thin wrapper around svg2tikz that converts draw.io diagrams to TikZ code for embedding in LaTeX documents.

Features

  • Converts either a single draw.io page or all pages
  • Preserves label colors, bold text, font sizes, and simple line breaks
  • Ignores draw.io font family names, allowing output to use the host LaTeX document font
  • Removes draw.io SVG CSS that svg2tikz cannot parse, including light-dark(...) from draw.io's dark mode color scheme
  • Restores draw.io labels emitted as SVG foreignObject elements, which draw.io exports as HTML fragments

Requirements

  • Python 3.14 or newer
  • drawio CLI available on PATH (install from diagrams.net or via Homebrew: brew install --cask drawio)

Installation

pip / uv

Install from PyPI:

uv tool install drawio2tikz

Or with pip:

pip install drawio2tikz

Development Setup

Clone the repository and install in development mode:

git clone https://github.com/daikiokayama/drawio2tikz.git
cd drawio2tikz
uv sync
uv run drawio2tikz --help

Usage

Basic Usage

Convert a single page from a draw.io file to TikZ:

drawio2tikz path/to/figure.drawio -o output_dir

This generates figure.tex in the output directory.

Convert All Pages

To convert all pages in a multi-page .drawio file:

drawio2tikz path/to/multipage.drawio --all-pages -o output_dir

Each page is saved as multipage-01.tex, multipage-02.tex, and so on.

Keep Intermediate SVG

To debug or inspect the intermediate SVG (after sanitization):

drawio2tikz path/to/figure.drawio -o output_dir --keep-svg --svg-dir output_dir/svg

View Help

drawio2tikz --help

LaTeX Setup

Add these packages to your LaTeX document preamble:

\usepackage{xcolor}
\usepackage{tikz}

Include the generated TikZ file:

\input{path/to/figure.tex}

For support of arbitrary large font sizes, use a scalable font:

\usepackage{mlmodern}

Example LaTeX Document

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{mlmodern}

\begin{document}

\section{My Diagram}

\begin{figure}
  \centering
  \input{figures/diagram.tex}
  \caption{A diagram created in draw.io}
\end{figure}

\end{document}

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests on GitHub.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drawio2tikz-0.5.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drawio2tikz-0.5.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file drawio2tikz-0.5.0.tar.gz.

File metadata

  • Download URL: drawio2tikz-0.5.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for drawio2tikz-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b7a79fd5c33d6de7621ac8d26515f202fc233e6347d3c85b4c29bb06f6c0bf8d
MD5 0ac68520005796bc14c52b2767b06b4a
BLAKE2b-256 b32cc058d5a760b9f43da97439c9733dcce312e28c303a1d16536f9aa6fff51e

See more details on using hashes here.

Provenance

The following attestation bundles were made for drawio2tikz-0.5.0.tar.gz:

Publisher: release.yml on okayama-daiki/drawio2tikz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drawio2tikz-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: drawio2tikz-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for drawio2tikz-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91877f9a1e627dda0fc5c2e306151433f95e8b590907c97b783023b0c088c576
MD5 4badd70ccc2078aeb335789613dc7070
BLAKE2b-256 3ac2b6c095d7fdbcddf08c85b1b6a806e054470bf138e8e9fcf4c05410cc6285

See more details on using hashes here.

Provenance

The following attestation bundles were made for drawio2tikz-0.5.0-py3-none-any.whl:

Publisher: release.yml on okayama-daiki/drawio2tikz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page