> For the complete documentation index, see [llms.txt](https://notes.tejpratapsingh.com/_/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.tejpratapsingh.com/_/javascript-tips/javascript-tips/save-blob-as-file.md).

# Save blob as File

To save a blob as file, you need its blob object first.

You can find it either by adding a debugger point in source code from JavaScript file (from sources tab in Dev Tools) or create your save blob from Network panel.

Now Just run this code snippit to save your file in disk.

```javascript
// application/pdf is set as example, please set correct MIME type here
let blob = new window.Blob([blobObject], { type: 'application/pdf' });
// Parse blob object to base64 to prevent chrome blocking:
let blobUrl = URL.createObjectURL(blob);

let link = document.createElement("a"); // Or maybe get it from the current document
link.href = blobUrl;
link.download = "file";
link.innerHTML = "Click here to download the file";

// Perform click to initiate download
link.click()
```

Now you can see a download prompt, just save this file.
