Thanks in advance,
is the bpmn-js command line interface an option for you?
You can check it out here: https://github.com/bpmn-io/bpmn-js-cli
Yes, that looks very nice. However, I am only able to use the CLI in the web browser console. How can I use it inside my own JS code?
Have a look at the unit tests for modeling. They serve as documentation, too.