Did you know ?
Google offers a secret URL that can automatically pull the favicon image of any domain. Cherries on the cake, we can ask for different sizes and the images returned are in PNG format (not ICO), meaning they will render correctly in all browsers using the <img>
tag.
The API works using a simple GET:
https://www.google.com/s2/favicons?domain=${domain}&sz=${size}
The query parameters are:
-
domain
: mandatory, the domain you are interested in, -
sz
: optional, a size hint such as256
.
In case the right size is not found, it will return the default one, usually 16x16.
https://www.google.com/s2/favicons?domain=dev.to&sz=128
https://www.google.com/s2/favicons?domain=dev.to&sz=512 (nothing found for 512x512, so returns a 16x16 PNG)
https://www.google.com/s2/favicons?domain=stackoverflow.com&sz=128 (yep, sometimes the quality is far from optimal)
Oldest comments (8)
Nice writeup! Privacy-friendly search engine DuckDuckGo also has one similar to the Google one:
Also there's one I made called Icon Horse that has some additional features:
Wasn't aware of those ones, nice to know thanks !
I would just state that Icon Horse is not free (but still a very nice tool).
Do you know if duckduckgo supports parameters, such as the size hint for example ?
To my knowledge DDG doesn’t have various customisation params available.
Icon Horse is free, but premium features cost money.
Icon horse seems quite nice! Big image, doesn't stop at redirections, very cool.
icon.horse is the best one... Thanks for the sharing
Your Icon Horse service looks amazing! I'll give it a try real soon.
Here is yet another service: favicongrabber.com
The call looks like:
The response is a JSON with all the available icons (use
?pretty=true
for nice json formatting):However, I got some gateway timeouts and trying favicongrabber.com/api/grab/stacko... currently returns:
Thanks for mentioning this ! I created a little cli to expose this api: github.com/pomdtr/fetch-favicon