var blob = new Blob(["hello,the world"], { type: 'text/plain' }); var objectUrl = URL.createObjectURL(blob); var a = document.createElement('a'); document.body.appendChild(a); a.setAttribute('style', 'display:none'); a.setAttribute('href', objectUrl); a.setAttribute('download', "text"); a.click(); document.body.removeChild(a) URL.revokeObjectURL(objectUrl);