FileSaver.js
An HTML5 saveAs() FileSaver implementation
FileSaver.js is a tiny JavaScript library that lets web apps trigger file downloads in the browser using a simple saveAs() function, no server needed for files generated entirely on the client side.
FileSaver.js is a JavaScript library that lets web applications trigger file downloads directly in the browser, without needing a server to send the file. It provides a simple saveAs() function that you call with the data you want to save and a filename, and the browser presents the user with a download.
The problem it solves is that web pages run inside a browser sandbox and cannot directly write to a user's file system. FileSaver.js works around this by creating a "Blob" — a browser-native object that holds arbitrary data in memory — and then triggering a download of that Blob. This makes it useful for web apps that generate content on the fly: for example, exporting a spreadsheet that was assembled in the browser, downloading a text file generated from a form, or saving an image that was drawn on an HTML canvas element.
You would use it when you are building a web app that needs to let users download files that were created or assembled entirely in the browser, rather than fetched from a server. Common scenarios include data export, report generation, and canvas image saving. If your files come from a server, the README recommends using a standard server-side HTTP header instead, which has broader browser compatibility.
The library supports a wide range of browsers. For very large files that exceed browser memory limits, the README points to a companion project called StreamSaver.js that writes directly to disk using streaming. FileSaver.js is installed via npm and is written in JavaScript with optional TypeScript type definitions available.
Where it fits
- Export a table from a web app as a downloadable CSV file that the user can save with one click.
- Let users save a drawing from an HTML canvas element as a PNG image file directly from the browser.
- Download a text report generated from a form submission without sending any data to a server first.