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.tikz 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 figure_page{N}.tikz.

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.tikz}

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.tikz}
  \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.1.1.tar.gz (8.8 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.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for drawio2tikz-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b086477a5d1b48a6c14d93bb0a3a446b664c1a2694eb29bc7a0a726082c54c84
MD5 88979519bb7f8dece98579988c4023f5
BLAKE2b-256 c4833f7cd7e6fdf987a1a731a110db425ed113a48965af961b215c1e8d85c407

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: drawio2tikz-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8607cf09cdc5c964f1248ab520b4a7aa4bdf9a9847c0fd2d869a349936607c3e
MD5 1f64c6dce693e2f24b4f00d6fd0058a4
BLAKE2b-256 5d7d827cc3e82b20d1253d2fbe48665c492a9a8139a40aaf48c6ec954af7c98a

See more details on using hashes here.

Provenance

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