What is favicons?
The favicons npm package is a tool for generating favicons and other related icons for web applications. It simplifies the process of creating various sizes and types of icons required for different devices and platforms.
What are favicons's main functionalities?
Generate Favicons
This feature allows you to generate favicons from a source image. The configuration object can be customized to specify different settings, and the callback function handles the generated icons, files, and HTML elements.
const favicons = require('favicons');
const source = 'path/to/logo.png';
const configuration = { /* configuration options */ };
const callback = (error, response) => {
if (error) {
console.log(error.message);
return;
}
console.log(response.images); // Array of { name: string, contents: <buffer> }
console.log(response.files); // Array of { name: string, contents: <string> }
console.log(response.html); // Array of strings (html elements)
};
favicons(source, configuration, callback);
Custom Configuration
This feature allows you to customize the configuration for generating favicons. You can specify various options such as the application name, description, background color, theme color, and more. The icons object allows you to enable or disable the creation of specific types of icons.
const favicons = require('favicons');
const source = 'path/to/logo.png';
const configuration = {
path: '/assets/icons', // Path for overriding default icons path
appName: 'My App', // Your application's name
appShortName: 'App', // Your application's short name
appDescription: 'This is my application', // Your application's description
developerName: 'Developer', // Your (or your developer's) name
developerURL: 'http://example.com', // Your (or your developer's) URL
background: '#020307', // Background color for flattened icons
theme_color: '#020307', // Theme color for browser chrome
display: 'standalone', // Android display: 'browser' or 'standalone'
orientation: 'portrait', // Android orientation: 'portrait' or 'landscape'
start_url: '/?homescreen=1', // Start URL when launching the application from a device
version: '1.0', // Your application's version string
logging: false, // Print logs to console?
pixel_art: false, // Keeps pixels 'sharp' when scaling up, for pixel art
loadManifestWithCredentials: false, // Browsers only
icons: {
android: true, // Create Android homescreen icon. `boolean` or `{ offset, background }`
appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background }`
appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background }`
coast: { offset: 25 }, // Create Opera Coast icon with offset 25%. `boolean` or `{ offset, background }`
favicons: true, // Create regular favicons. `boolean`
firefox: true, // Create Firefox OS icons. `boolean` or `{ offset, background }`
windows: true, // Create Windows 8 tile icons. `boolean` or `{ background }`
yandex: true // Create Yandex browser icon. `boolean` or `{ background }`
}
};
const callback = (error, response) => {
if (error) {
console.log(error.message);
return;
}
console.log(response.images); // Array of { name: string, contents: <buffer> }
console.log(response.files); // Array of { name: string, contents: <string> }
console.log(response.html); // Array of strings (html elements)
};
favicons(source, configuration, callback);
Other packages similar to favicons
gulp-favicons
The gulp-favicons npm package is a Gulp plugin for generating favicons. It provides similar functionalities to favicons but is designed to be used within a Gulp build process. This makes it a good choice for developers who are already using Gulp for their build tasks and want to integrate favicon generation into their workflow.
favicons-webpack-plugin
The favicons-webpack-plugin npm package is a Webpack plugin for generating favicons. It offers similar functionalities to favicons but is designed to be used within a Webpack build process. This makes it a good choice for developers who are using Webpack for their build tasks and want to integrate favicon generation into their workflow.
Favicons

A Node.js module for generating favicons and their associated files. Originally built for Google's Web Starter Kit and Catalyst. Installed through NPM with:
npm install favicons
Usage
To use Favicons, require the appropriate module and call it, optionally specifying configuration and callback objects. A sample is shown on the right. The full list of options can be found on GitHub.
Favicons generates its icons locally using pure Javascript with no external dependencies.
Please note: Favicons is tested on Node 14 and above.
import { favicons } from "favicons";
const source = "test/logo.png";
const configuration = {
path: "/",
appName: null,
appShortName: null,
appDescription: null,
developerName: null,
developerURL: null,
cacheBustingQueryParam: null,
dir: "auto",
lang: "en-US",
background: "#fff",
theme_color: "#fff",
appleStatusBarStyle: "black-translucent",
display: "standalone",
orientation: "any",
scope: "/",
start_url: "/?homescreen=1",
preferRelatedApplications: false,
relatedApplications: undefined,
version: "1.0",
pixel_art: false,
loadManifestWithCredentials: false,
manifestMaskable: false,
icons: {
android: true,
appleIcon: true,
appleStartup: true,
favicons: true,
windows: true,
yandex: true,
},
shortcuts: [
{
name: "View your Inbox",
short_name: "inbox",
description: "View your inbox messages",
url: "/inbox",
icon: "test/inbox_shortcut.png",
},
],
};
try {
const response = await favicons(source, configuration);
console.log(response.images);
console.log(response.files);
console.log(response.html);
} catch (error) {
console.log(error.message);
}
The default sources are as follow (groupped by platform):
{
"android": [
"android-chrome-144x144.png",
"android-chrome-192x192.png",
"android-chrome-256x256.png",
"android-chrome-36x36.png",
"android-chrome-384x384.png",
"android-chrome-48x48.png",
"android-chrome-512x512.png",
"android-chrome-72x72.png",
"android-chrome-96x96.png"
],
"appleIcon": [
"apple-touch-icon-1024x1024.png",
"apple-touch-icon-114x114.png",
"apple-touch-icon-120x120.png",
"apple-touch-icon-144x144.png",
"apple-touch-icon-152x152.png",
"apple-touch-icon-167x167.png",
"apple-touch-icon-180x180.png",
"apple-touch-icon-57x57.png",
"apple-touch-icon-60x60.png",
"apple-touch-icon-72x72.png",
"apple-touch-icon-76x76.png",
"apple-touch-icon-precomposed.png",
"apple-touch-icon.png"
],
"appleStartup": [
"apple-touch-startup-image-1125x2436.png",
"apple-touch-startup-image-1136x640.png",
"apple-touch-startup-image-1242x2208.png",
"apple-touch-startup-image-1242x2688.png",
"apple-touch-startup-image-1334x750.png",
"apple-touch-startup-image-1536x2048.png",
"apple-touch-startup-image-1620x2160.png",
"apple-touch-startup-image-1668x2224.png",
"apple-touch-startup-image-1668x2388.png",
"apple-touch-startup-image-1792x828.png",
"apple-touch-startup-image-2048x1536.png",
"apple-touch-startup-image-2048x2732.png",
"apple-touch-startup-image-2160x1620.png",
"apple-touch-startup-image-2208x1242.png",
"apple-touch-startup-image-2224x1668.png",
"apple-touch-startup-image-2388x1668.png",
"apple-touch-startup-image-2436x1125.png",
"apple-touch-startup-image-2688x1242.png",
"apple-touch-startup-image-2732x2048.png",
"apple-touch-startup-image-640x1136.png",
"apple-touch-startup-image-750x1334.png",
"apple-touch-startup-image-828x1792.png",
"apple-touch-startup-image-1179x2556.png",
"apple-touch-startup-image-2556x1179.png",
"apple-touch-startup-image-1290x2796.png",
"apple-touch-startup-image-2796x1290.png",
"apple-touch-startup-image-1488x2266.png",
"apple-touch-startup-image-2266x1488.png",
"apple-touch-startup-image-1640x2360.png",
"apple-touch-startup-image-2360x1640.png"
],
"favicons": [
"favicon-16x16.png",
"favicon-32x32.png",
"favicon-48x48.png",
"favicon.ico"
],
"windows": [
"mstile-144x144.png",
"mstile-150x150.png",
"mstile-310x150.png",
"mstile-310x310.png",
"mstile-70x70.png"
],
"yandex": [
"yandex-browser-50x50.png"
]
}
You can programmatically access Favicons configuration (icon filenames, HTML, manifest files, etc) with:
import { config } from "favicons";
Below you will find a simple working example to generate an output. Amend the src
, dest
, htmlBasename
and configuration
constants to suit your own needs.
import favicons from "favicons";
import fs from "fs/promises";
import path from "path";
const src = "./icon.svg";
const dest = "./favicons";
const htmlBasename = "index.html";
const configuration = {
path: "/favicons",
appName: "My Great App",
appShortName: "Great App",
appDescription: "A great application to test itgalaxy/favicons.",
};
const response = await favicons(src, configuration);
await fs.mkdir(dest, { recursive: true });
await Promise.all(
response.images.map(
async (image) =>
await fs.writeFile(path.join(dest, image.name), image.contents),
),
);
await Promise.all(
response.files.map(
async (file) =>
await fs.writeFile(path.join(dest, file.name), file.contents),
),
);
await fs.writeFile(path.join(dest, htmlBasename), response.html.join("\n"));
Questions
Why are you missing certain favicons?
Because pure Javascript modules aren't available at the moment. For example, the El Capitan SVG favicon and the Windows tile silhouette ability both require SVG support. If modules for these task begin to appear, please jump on the appropriate issue and we'll get on it ASAP.
Thank you
Contribution
Feel free to push your code if you agree with publishing under the MIT license.
When testing, don't forget to update snapshots whenever you edit them: npm test -- -u
.