Import and Export
8 min read
Export Tasks as JSON
Find the export control in index.html and connect it in script.js.
Create a JSON string from the current task data:
const exportData = JSON.stringify(tasks, null, 2);
Then create a downloadable file:
const blob = new Blob([exportData], { type: "application/json" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "todo-list.json";
link.click();
URL.revokeObjectURL(url);
Attach this logic to the prepared export button rather than changing the visual design.
Checkpoint
Add several tasks, edit their details, reorder them, and click Export. A todo-list.json file should be downloaded.