https://github.com/okayama-daiki/drawio2tikz
A converter from draw.io (diagrams.net) to TikZ
https://github.com/okayama-daiki/drawio2tikz
converter drawio hobby tikz vibe-coding
Last synced: 19 days ago
JSON representation
A converter from draw.io (diagrams.net) to TikZ
- Host: GitHub
- URL: https://github.com/okayama-daiki/drawio2tikz
- Owner: okayama-daiki
- License: mit
- Created: 2025-11-08T03:11:15.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2026-04-28T12:52:20.000Z (about 2 months ago)
- Last Synced: 2026-04-28T14:12:24.846Z (about 2 months ago)
- Topics: converter, drawio, hobby, tikz, vibe-coding
- Language: Python
- Homepage: https://drawio2tikz.daiki.dev
- Size: 94.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# drawio2tikz
`drawio2tikz` is a thin wrapper around [`svg2tikz`](https://github.com/xyz2tex/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](https://diagrams.net) or via Homebrew: `brew install --cask drawio`)
## Installation
### pip / uv
Install from PyPI:
```bash
uv tool install drawio2tikz
```
Or with pip:
```bash
pip install drawio2tikz
```
### Development Setup
Clone the repository and install in development mode:
```bash
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:
```bash
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:
```bash
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):
```bash
drawio2tikz path/to/figure.drawio -o output_dir --keep-svg --svg-dir output_dir/svg
```
### View Help
```bash
drawio2tikz --help
```
## LaTeX Setup
Add these packages to your LaTeX document preamble:
```tex
\usepackage{xcolor}
\usepackage{tikz}
```
Include the generated TikZ file:
```tex
\input{path/to/figure.tex}
```
For support of arbitrary large font sizes, use a scalable font:
```tex
\usepackage{mlmodern}
```
### Example LaTeX Document
```tex
\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](https://github.com/daikiokayama/drawio2tikz).
## License
MIT