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;