# Pastebin vqAEYLq7 const regex = /["\\]/; const escape_replace_regex = /["\\]/g; function stringify (obj) { var str = '', key; for (key in obj) { let v = obj[key]; if (v == null) { str += `${key}="" `; continue; } v = v.toString(); if (regex.test(v)) { str += `${key}="${v.replace(escape_replace_regex, '\\$&')}" `; } else { str += `${key}="${v}" `; } } return str.trim(); };