var array = [{ x: 0, y: 0 }]; var a = document.body.appendChild( document.createElement("a") ); a.download = "export.txt"; a.href = "data:text/plain;base64," + btoa(JSON.stringify(array)); a.innerHTML = "download example text";