The File System Access API is a browser interface that lets a web page read, write and save files and directories on the user’s local device through handles obtained from native file pickers, with access controlled by explicit user permission. Among Web APIs, it is the one that allows editors, design tools and integrated development environments in the browser to work with real files instead of uploads and downloads.
The API was incubated in the Web Platform Incubator Community Group and shipped in Chromium-based browsers in 2020. Part of the underlying model, the origin private file system, was later standardized in the WHATWG File System specification and is supported by all major engines, while the picker-based access to user files remains limited to Chromium.
How the File System Access API works
The API is built on handles rather than paths. A page never sees or types a file path; instead it calls a picker method, the browser shows the native operating system dialog, and the user’s choice is returned as a FileSystemFileHandle or FileSystemDirectoryHandle object.
Pickers can be opened only in response to a user gesture, such as a click, and only in a secure context served over HTTPS or from localhost. The following table summarizes the main entry points and what each returns.
| Method | Returns | Typical use |
|---|---|---|
| showOpenFilePicker() | Array of file handles | Open one or more existing documents |
| showSaveFilePicker() | One file handle | Save As to a new or chosen file |
| showDirectoryPicker() | Directory handle | Open a project folder |
| handle.getFile() | File object | Read contents as text, stream or buffer |
| handle.createWritable() | Writable file stream | Write and commit changes |
| dirHandle.values() | Async iterator of entries | List files and subfolders |
Writing uses a FileSystemWritableFileStream. Data is first written to a temporary swap file, and the original is replaced only when the stream is closed. This design means that an interrupted save does not leave a half-written document, and it gives the browser a point at which to run Safe Browsing checks before the data reaches disk.
Permission model and security safeguards
Security rests on the principle that the user chooses every file or folder the page can touch. Selecting a file in the open picker grants read access; writing requires a separate write permission, which the browser requests in a prompt the first time the page tries to save.
Handles can be stored in IndexedDB so that an application can offer a list of recent files, but permissions do not automatically survive. When a stored handle is used again, the page calls queryPermission() and, if needed, requestPermission(), which triggers a fresh prompt. The table below lists the main safeguards.
| Safeguard | What it prevents | How it is enforced |
|---|---|---|
| User activation required | Silent background access | Pickers open only after a click or key press |
| Secure context only | Interception of file data | Unavailable on plain HTTP pages |
| Blocked locations | Access to system folders | Browser refuses sensitive directories |
| Separate write permission | Unnoticed modification | Prompt before the first write |
| Swap file and checks | Partial or malicious writes | Commit only when the stream closes |
| Visible access indicator | Forgotten open permissions | Icon in the address bar |
Browsers also restrict the API in cross-origin iframes and refuse to open the root of the system drive or folders such as the operating system directory. Even so, Mozilla and Apple have argued that granting websites write access to user files carries risks that ordinary users cannot assess, which is why their engines do not implement the pickers.
The origin private file system
The origin private file system, often abbreviated OPFS, is a storage area that belongs to one origin and is invisible to the user in the operating system. It is reached with navigator.storage.getDirectory(), requires no picker and no permission prompt, and counts against the origin’s storage quota.
Its key strength is speed. In a dedicated worker, createSyncAccessHandle() provides synchronous, in-place reads and writes, which makes OPFS a practical backend for WebAssembly databases such as SQLite compiled to the browser. The comparison below separates the two parts of the API.
| Property | User-visible files | Origin private file system |
|---|---|---|
| Access method | Native pickers | navigator.storage.getDirectory() |
| User permission | Required per file or folder | Not required |
| Visible in file manager | Yes | No |
| Browser support | Chromium-based browsers | All major engines |
| Synchronous access | No | Yes, in workers |
| Typical use | Document and code editors | Databases, caches, working files |
How it compares with other storage and file options
The API fills a gap that older web file mechanisms could not cover: saving back to the same file. The table below places it among related Web APIs and classic techniques.
| Option | Can write to user files | Main limitation |
|---|---|---|
| input type file | No | Read-only copy of the selected file |
| Download link | Creates a new file only | Cannot overwrite the original |
| File System Access API | Yes, after permission | Limited browser support for pickers |
| IndexedDB | No | Data stays inside browser storage |
| Web Storage API | No | Small, synchronous, string-only storage |
Because support is uneven, production applications use feature detection and fall back to file inputs and downloads when showOpenFilePicker is missing. Small open-source wrapper libraries implement exactly this progressive enhancement pattern.
Practical limitations and common mistakes
- Calling a picker without a user gesture throws a SecurityError, for example when it runs after an awaited network request.
- Forgetting to call close() on a writable stream leaves the changes uncommitted in the swap file.
- Assuming stored handles keep their permission leads to failed saves; always re-check permission on reuse.
- Treating OPFS as backup storage is risky, because clearing site data deletes it without warning.
- Writing large files in many tiny chunks is slow; buffer data and write in larger blocks.
Developers should also remember that folder access is recursive. Granting a directory handle exposes every file below it, so applications should ask for the narrowest folder they need and explain why before opening the picker.
Put simply
Normally a website can only take a copy of a file you upload, and it gives back a new copy when you download. It cannot change the original file on your computer.
The File System Access API changes that, but only with your permission. You pick a file or folder in the usual window from your computer, and the website may then open it and save changes back to the same file, much like a desktop program. Without your choice, the site sees nothing.
In practice
A technical writer maintains a documentation project of about 300 Markdown files on a company laptop and uses a browser-based editor instead of an installed program.
She clicks Open folder, chooses the project directory in the system dialog and confirms the prompt. The editor lists the files through the directory handle, and every press of Ctrl+S writes the change straight to disk through a writable stream. The editor stores the handle in IndexedDB, so the next morning one click and one permission prompt reopen the same folder.
Her changes appear immediately in the local Git client, with no upload, download or duplicate files. On a colleague’s browser without picker support, the same editor falls back to file uploads and downloads, which still works but requires saving each file manually.