This browser snippet allows you to download all favicons from a web page into a structured folder using the File System Access API.
It automatically generates smart filenames based on the type of favicon (apple-touch-icon, mask-icon, favicon) and the actual image dimensions.
It also creates a simple example.html referencing all the saved icons with correct rel, sizes, and mask-color attributes.
- Prompts the user to select a folder where all favicons will be saved.
- Creates a main folder named
<host> iconsand anicons/subfolder. - Supports all common favicon types:
favicon.icofavicon.pngin different sizesapple-touch-iconmask-icon(includingcolorattribute)
- Determines image dimensions using
createImageBitmapfor raster images (PNG, ICO). - For SVGs, falls back to
sizesattribute or defaults toauto. - Generates
example.htmlthat includes proper<link>tags for all saved icons.
- Open the web page in your browser.
- Open DevTools → Console.
- Paste the snippet from
download-favicons.js. - Press Enter.
- A folder picker will appear — choose a folder to store the favicons.
- The script will:
- Create a
<host> iconsfolder. - Create an
icons/subfolder with all downloaded favicons. - Create
example.htmlreferencing all icons.
- Create a
- SVGs cannot be decoded by
createImageBitmap, so the script readssizesif available. - If multiple
<link>elements point to the same file, the script will download them separately (no deduplication). - Works only in browsers that support the File System Access API (Chrome, Edge, Opera, and some Chromium-based browsers).
- The script will log all saved filenames and errors in the console.
<host> icons/
├── icons/
│ ├── apple-touch-icon-180x180.png
│ ├── favicon-32x32.png
│ ├── mask-icon-auto x auto.svg
│ └── ...
└── example.html