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
svg2tikzcannot parse, includinglight-dark(...)from draw.io's dark mode color scheme - Restores draw.io labels emitted as SVG
foreignObjectelements, which draw.io exports as HTML fragments
Requirements
- Python 3.14 or newer
drawioCLI available onPATH(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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9883423e1af5cc3f851308a3afa5bc7a77d30f541ab2ac802f761d52569e980
|
|
| MD5 |
c5a0287edbfc340578d958fc9e57969a
|
|
| BLAKE2b-256 |
7b3532192299c45193fd984927fcff74b85c7fa384e256ba8b767cf112bbad92
|
Provenance
The following attestation bundles were made for drawio2tikz-0.3.0.tar.gz:
Publisher:
release.yml on okayama-daiki/drawio2tikz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drawio2tikz-0.3.0.tar.gz -
Subject digest:
f9883423e1af5cc3f851308a3afa5bc7a77d30f541ab2ac802f761d52569e980 - Sigstore transparency entry: 1400114973
- Sigstore integration time:
-
Permalink:
okayama-daiki/drawio2tikz@7ca1ad41bd4165afc7a0094b9bb17e9cd7533830 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/okayama-daiki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ca1ad41bd4165afc7a0094b9bb17e9cd7533830 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca394ca62c89d025cee043ef2057517656fecec44a9fc936c240a9502aa5e0c
|
|
| MD5 |
e041782c277bf3080a42ed91a9b3acad
|
|
| BLAKE2b-256 |
6c3c7b3ded094fe446e7a391313386312ab885b67a7002b453ddcf09826ccebf
|
Provenance
The following attestation bundles were made for drawio2tikz-0.3.0-py3-none-any.whl:
Publisher:
release.yml on okayama-daiki/drawio2tikz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drawio2tikz-0.3.0-py3-none-any.whl -
Subject digest:
dca394ca62c89d025cee043ef2057517656fecec44a9fc936c240a9502aa5e0c - Sigstore transparency entry: 1400115128
- Sigstore integration time:
-
Permalink:
okayama-daiki/drawio2tikz@7ca1ad41bd4165afc7a0094b9bb17e9cd7533830 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/okayama-daiki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ca1ad41bd4165afc7a0094b9bb17e9cd7533830 -
Trigger Event:
push
-
Statement type: