
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
favicon-extractor
Advanced tools
A lightweight Node.js utility to fetch and extract favicons from any website URL. Perfect for developers who need quick access to site icons for apps, extensions, or APIs.
A lightweight Node.js backend utility to fetch and extract favicons from any website URL. Designed specifically for server-side applications, APIs, and backend services that need quick access to site icons.
npm install favicon-extractor
or with Yarn:
yarn add favicon-extractor
Note: This package is designed for backend/server-side use only and requires a Node.js environment.
import getFavicons, { getFavicon, type BatchResult } from "favicon-extractor";
// Fetch favicons from multiple URLs
const Favicons = await getFavicons([
"https://www.google.com",
"https://www.github.com",
]);
console.log(Favicons);
// Fetch favicon from a single URL
const Favicon = await getFavicon("https://www.google.com");
console.log(Favicon);
// TypeScript usage with interface
const favicon: BatchResult = await getFavicon("https://www.example.com");
const { getFavicons, getFavicon, BatchResult } = require("favicon-extractor");
// Usage remains the same
const favicon = await getFavicon("https://www.example.com");
interface BatchResult {
url: string;
hostname: string | null;
favicon: string | null;
success: boolean;
error?: string;
}
The package exports the BatchResult interface for TypeScript users to ensure type safety when working with the returned favicon data.
getFavicons(urls: string[]): Promise<BatchResult[]>Fetch favicons for multiple URLs.
Parameters:
urls (string[]): Array of website URLs to extract favicons fromReturns:
Promise<BatchResult[]>: An array of BatchResult objectsExample:
const favicons = await getFavicons([
"https://www.google.com",
"https://www.github.com"
]);
getFavicon(url: string): Promise<BatchResult>Fetch favicon for a single URL.
Parameters:
url (string): Website URL to extract favicon fromReturns:
Promise<BatchResult>: A BatchResult object with detailed informationExample:
const favicon = await getFavicon("https://www.google.com");
[
{
"url": "https://www.google.com",
"hostname": "google",
"favicon": "https://www.google.com/s2/favicons?domain=google.com&sz=64",
"success": true
},
{
"url": "https://www.github.com",
"hostname": "github",
"favicon": "https://www.google.com/s2/favicons?domain=github.com&sz=64",
"success": true
}
]
{
"url": "https://brew.beer",
"hostname": "brew",
"favicon": "https://www.google.com/s2/favicons?domain=brew.beer&sz=64",
"success": true
}
{
"url": "https://invalid-site.com",
"hostname": "invalid-site",
"favicon": null,
"success": false,
"error": "Request timeout"
}
Set custom timeout values for requests to handle slow-responding websites:
// 10 second timeout for a single favicon
const favicon = await getFavicon("https://slow-website.com", {
timeout: 10000
});
// 3 second timeout for batch processing
const favicons = await getFavicons(urls, { timeout: 3000 });
Some websites may block requests without proper user agents:
const favicon = await getFavicon("https://protected-site.com", {
userAgent: "Mozilla/5.0 (compatible; MyBot/1.0)"
});
Control how many simultaneous requests are made when processing multiple URLs:
// Process 3 URLs at a time instead of all at once
const favicons = await getFavicons(manyUrls, {
concurrency: 3
});
The package gracefully handles various error scenarios:
success: false with favicon: null and optional error messagesuccess: false with favicon: null and error: "Request timeout"success: false with favicon: nullnull if extraction fails)error field provides additional context when failures occurThis package is specifically designed for backend environments and requires:
Not suitable for:
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © Nitish Kumar M
Keywords: favicon, icon, website, scraper, extractor, url, node.js, javascript, utility, backend, server-side
FAQs
A lightweight Node.js utility to fetch and extract favicons from any website URL. Perfect for developers who need quick access to site icons for apps, extensions, or APIs.
We found that favicon-extractor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.