Have a look at the generateJSON utility we wrote for tiptap:
It’s using hostic-dom, which based on some Vue 3 internals.
It takes a string and outputs JSON, the opposite way (generateHTML) can be found in the same folder. Works in the browser context and in Node.js.
Hope that helps!