URL
fileURLToPath()
Converts a file URL into a filesystem path with percent decoding and platform rules. Tested on Node.js 22.16.0. Do not substitute URL.pathname for file conversion; conversion does not authorize file access.
Formal Syntax & Structure
nodejs syntaxnodejs
fileURLToPath(url[, options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| url | URL | string | File URL. |
| options | object | Optional windows selector (default platform). |
Return Value
string
Filesystem path.
Working Example
Example Snippetnodejs
import { URL, URLSearchParams, fileURLToPath, pathToFileURL } from 'node:url';console.log(fileURLToPath('file:///catalog/my%20book.txt',{windows:false}));