graphviz2drawio
June 17, 2026 · View on GitHub
Convert graphviz (dot) files to draw.io / lucid (mxGraph) format. Beautiful and editable graphs in your favorite editor.
Installation
macOS
graphviz2drawio can be installed with Homebrew:
brew install graphviz2drawio
Linux
It is recommended to use pipx to install and run the CLI tool. If you wish to use the library, you can install with pip instead.
Note that the graphviz library is required before installing this package.
Ubuntu / Debian
sudo apt update
sudo apt install pipx graphviz graphviz-dev
pipx install graphviz2drawio
# To update: pipx upgrade graphviz2drawio
Fedora
sudo dnf install pipx
pipx ensurepath
pipx install graphviz2drawio
# To update: pipx upgrade graphviz2drawio
Anaconda
conda install conda-forge::graphviz2drawio
Usage
Run the conversion app on your graphviz file. For example, the command below will create converted files example1.xml and example2.xml.
graphviz2drawio example1.dot example2.dot
Alternatively, you can specify the output file (but only if there is a single input file)
graphviz2drawio example.dot -o /path/to/somewhere/new_name.xml
Output can also be sent to stdout by using the --stdout flag.
Graphs can be piped in from stdin and sent to stdout (default) or to a file with -o ....
Library Usage
from graphviz2drawio import graphviz2drawio
graph_to_convert = ...
xml = graphviz2drawio.convert(graph_to_convert)
print(xml)
where graph_to_convert can be any of a file path, file handle, string of dot language, or PyGraphviz.AGraph object
Built With
- PyGraphviz - Python interface to Graphviz
- svg.path - SVG path objects and parser
Contributing
Pull requests and issue reports are welcome. For major changes, please open an issue first to discuss what you would like to change.
To see architectural and process diagrams please visit the deepwiki page
Thanks to all the people who have contributed to this project!
Development Setup
uv is used for packaging and dependency management.
git clone git@github.com:hbmartin/graphviz2drawio.git
cd graphviz2drawio
uv sync
# Replace with the actual path to your dot files
uv run python -m graphviz2drawio test/directed/hello.gv.txt
On macOS (Apple Silicon), pygraphviz compiles a C extension against Graphviz,
and Homebrew's /opt/homebrew is not on the default compiler search path. If
uv sync fails to build pygraphviz (clang error about missing
graphviz/cgraph.h), install Graphviz and rebuild that package with the
Homebrew paths:
brew install graphviz
CFLAGS="-I$(brew --prefix graphviz)/include" \
LDFLAGS="-L$(brew --prefix graphviz)/lib" \
uv sync --reinstall-package pygraphviz
Spec tests
Spec XMLs are stored separately for macOS and Linux because graph layout depends
on platform font metrics. The spec test runner automatically compares against
specs/mac/ on macOS and specs/linux/ on Linux.
The scripts invoke python3 directly, so run the native (macOS) variants
through uv run so they resolve to the project venv. The spec_env.sh variants
run inside Docker and already have the venv on PATH.
uv run ./scripts/test_specs.sh test/ tmp_out/
./scripts/spec_env.sh ./scripts/test_specs.sh test/ tmp_out/
uv run ./scripts/generate_specs.sh test/ specs/mac/
./scripts/spec_env.sh ./scripts/generate_specs.sh test/ specs/linux/
Roadmap
- Support compatible arrows
- Support multiple edges
- Support edges with links
Legal
© Harold Martin - released under GPLv3
diagrams.net is a trademark and draw.io is a registered trademark of JGraph Limited.