Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Drawio JS MxGraph XML compress uncompress

11 Jun 2022 »

From https://jgraph.github.io/drawio-tools/tools/convert.html

compress

data = document.getElementById('textarea')
data = encodeURIComponent(data)
data = String.fromCharCode.apply(null, new Uint8Array(pako.deflateRaw(data)));
data = btoa(data);

uncompress

var diagrams = node.getElementsByTagName('diagram');
data = atob(data);
data = bytesToString(pako.inflateRaw(data));
data = decodeURIComponent(data);
document.getElementById('textarea').value = data;