Skip to content

Instantly share code, notes, and snippets.

@LishuGupta652
Created October 4, 2020 05:27
Show Gist options
  • Save LishuGupta652/7338f7757b8901f0d4ff2e9fb3c2aec5 to your computer and use it in GitHub Desktop.
Save LishuGupta652/7338f7757b8901f0d4ff2e9fb3c2aec5 to your computer and use it in GitHub Desktop.
const filename = 'data.json';
const jsonStr = JSON.stringify(JsonExport);
let element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(jsonStr));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment