This is a functional script, available in both perl and python, used to demonstrate how to convert a file with PlantUML code into a Diagrams.net (a.k.a Draw.io) XML file from the command line. The PlantUML code and rendered SVG are embedded into the Diagrams.net/Draw.io document.
Both plantuml_to_drawio_xml.pl (perl) and plantuml_to_drawio_xml.py (python), written for the purpose of describing the transformation process, perform the same workflow and produce the same output.
In the Diagrams.net or Draw.io program, the PlantUML diagram can be double-clicked on to see the PlantUML source code. If the PlantUML library is loaded, the PlantUML code can be edited and saved which will update the diagram.
This script requires java and the PlantUML compiled Jar. It was last tested with OpenJDK 21, PlantUML 1.2024.4, and Draw.io 24.3.1.
@startuml
Cat -> Mouse : eats
@endumlsystem> ./plantuml_to_drawio_xml.pl cat-eats-mouse.plantuml > cat-eats-mouse.drawio.xml- 
in diagrams.net open new
- File > Open from > Device...
- choose the file cat-eats-mouse.drawio.xml
 
 
 - File > Open from > Device...
 - 
in diagrams.net import into existing document
- File > Import from > Device...
- choose the file cat-eats-mouse.drawio.xml
 
 
 - File > Import from > Device...
 
Comments in the code describe the steps to convert PlantUML to Diagram.net or Draw.io xml file
- Convert PlantUML plain text data to SVG data using java and the PlantUML jar
 - Encode the PlantUML SVG data using Base64
 - Encode the PlantUML text data for XML/HTML/URL format
 - Obtain the SVG dimensions from he SVG data to add into the Draw.io XML parameters
 - Obtain the last modified date of the PlantUML file to set as the revision date in the Draw.io XML parameters
 - Create the Draw.io XML file and output to standard out
 
There are several properties that can be changed in the plantuml_to_drawio_xml.pl file. Open the file and look at the top. The path to Java and the PlantUML jar can be changed as well as a few Draw.io ID properties.
Apache License 2.0, see LICENSE.
This program is free software