Skip to main content

Convert diagrams.net/draw.io diagrams to TikZ via SVG.

Project description

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

Project details


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.3.0.tar.gz (9.9 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.3.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for drawio2tikz-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9883423e1af5cc3f851308a3afa5bc7a77d30f541ab2ac802f761d52569e980
MD5 c5a0287edbfc340578d958fc9e57969a
BLAKE2b-256 7b3532192299c45193fd984927fcff74b85c7fa384e256ba8b767cf112bbad92

See more details on using hashes here.

Provenance

The following attestation bundles were made for drawio2tikz-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: drawio2tikz-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dca394ca62c89d025cee043ef2057517656fecec44a9fc936c240a9502aa5e0c
MD5 e041782c277bf3080a42ed91a9b3acad
BLAKE2b-256 6c3c7b3ded094fe446e7a391313386312ab885b67a7002b453ddcf09826ccebf

See more details on using hashes here.

Provenance

The following attestation bundles were made for drawio2tikz-0.3.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.

Supported by

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