PM4Py provides support for importing, exporting, and laying out BPMN diagrams. The supported BPMN elements are limited to the following:
Additionally, we offer functionality for converting between BPMN models and other process models implemented in PM4Py, such as Petri nets and BPMN diagrams.
BPMN 2.0 XML files can be imported using the following instructions:

BPMN models can be exported using the following instructions. In this case, bpmn_graph is the Python object containing the model.
Layouting aims to arrange the nodes and edges of the BPMN diagram in an aesthetically pleasing manner. For this purpose, PM4Py provides robust functionality for laying out and visualizing Business Process Model and Notation (BPMN) diagrams, including exporting diagrams in XML format, visualizing them on-screen, and saving visualizations to files with various layouts.
PM4Py allows users to export BPMN diagrams in XML format, which can be imported into BPMN editors such as BPMN.IO or Camunda. The export functionality includes options for automatic layouting of diagram elements.
Auto-Layout Parameter:
auto_layout=True - Includes coordinates for diagram elements and waypoints for edges, ensuring a structured layout.auto_layout=False - No layouting is performed. Imported BPMNs retain original coordinates, and automatically discovered BPMNs are exported without layouting.Dependency: The layouting process requires the Graphviz package to be installed.
PM4Py provides methods to visualize BPMN diagrams on-screen or save them to files, with two rendering variants for flexibility in visualization formats and styles.
Renders the BPMN diagram on-screen.
Saves the BPMN visualization to a file in the specified format.
png, svg, pdf, and other formats compatible with Graphviz.
Converting a BPMN model to a Petri net model allows the use of various PM4Py algorithms, such as conformance checking and simulation. This is a key operation in process mining. To convert a BPMN model into an (accepting) Petri net, you can use the following code:

Process trees are an important class of block-structured process models, often generated by the inductive miner algorithm. These models can easily be converted to BPMN models. Here's an example: First, we import an XES event log and discover a process model using the inductive miner:

Next, we can convert the discovered model into a BPMN graph:
