About ICO icon files
image/vnd.microsoft.icon is the registered name, but image/x-icon is what most servers send, and browsers accept both. Today a favicon can just as well be a PNG or SVG declared with <link rel="icon">; keep a /favicon.ico only for tools that request it without reading your HTML.
Other types seen for these files:
image/x-icon
. Accept them when reading uploads, but send image/vnd.microsoft.icon yourself.
File signature
ICO files start with 00 00 01 00. The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .ico with the right Content-Type
Content-Type: image/vnd.microsoft.icon
image/vnd.microsoft.icon ico;
AddType image/vnd.microsoft.icon .ico
@ico path *.ico
header @ico Content-Type "image/vnd.microsoft.icon"
curl -sI https://example.com/file.ico | grep -i '^content-type'
# Content-Type: image/vnd.microsoft.icon
Set the type in code
res.set('Content-Type', 'image/vnd.microsoft.icon');
// Or make the browser download it:
res.attachment('file.ico');
import mimetypes
mimetypes.add_type('image/vnd.microsoft.icon', '.ico') # if your system doesn't know it
mimetypes.guess_type('file.ico')[0] # 'image/vnd.microsoft.icon'
mime.AddExtensionType(".ico", "image/vnd.microsoft.icon")
w.Header().Set("Content-Type", "image/vnd.microsoft.icon")
Accept .ico uploads
<input type="file" accept=".ico,image/vnd.microsoft.icon">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
-
.png (
image/png): PNG image -
.svg (
image/svg+xml): SVG image -
.webmanifest (
application/manifest+json): Web app manifest
More images
.jpg , .gif , .webp , .avif , .heic , .bmp , .tiff . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .ico files?
image/vnd.microsoft.icon. You may also see image/x-icon, which is older or unofficial; send image/vnd.microsoft.icon. The full header is "Content-Type: image/vnd.microsoft.icon".
Why does my server send the wrong Content-Type for .ico?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .ico is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is ICO?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. ICO files start with 00 00 01 00. The MIME type lookup on this site reads them for you when you drop a file on it.