All formats

ICO (Windows Icon)

Full nameWindows Icon (ICO); Windows Cursor (CUR) is the same container
Extensions.ico (icon), .cur (cursor)
MIME typeimage/vnd.microsoft.icon (registered), image/x-icon (common)
Typecontainer of raster images (BMP/DIB or PNG), lossless
Starts with00 00 01 00 (ICO), 00 00 02 00 (CUR)
Specificationno formal spec; Microsoft documents it in Icons (Win32)
Maintained byMicrosoft
Licenseopen, no royalties

An ICO file is a small directory of images: the same icon drawn at several sizes and color depths, for example 16x16, 32x32, 48x48 and 256x256. Windows picks the entry that best matches the size it needs (taskbar, Explorer, title bar, high-DPI screens). Each entry is either a BMP-style bitmap with a transparency mask or a complete PNG file.

ICO is used for Windows application and file icons and for favicon.ico, the site icon browsers request from the root of a web server. A CUR file is the same structure with type 2 and a hotspot (the click point) per entry instead of planes and bit depth. Animated cursors (.ani) are a different, RIFF-based format that contains ICO/CUR frames.

When to use ICO#

File structure#

An ICO file has 3 parts: a 6-byte ICONDIR header, one 16-byte ICONDIRENTRY per image, and the image data. All integers are little-endian.

00 00                     reserved, must be 0
01 00                     type: 1 = icon (ICO), 2 = cursor (CUR)
01 00                     number of images: 1
-- ICONDIRENTRY #1 --
20                        width: 32 (0 means 256)
20                        height: 32 (0 means 256)
00                        colors in palette: 0 (no palette)
00                        reserved
01 00                     ICO: color planes (0 or 1)   CUR: hotspot X
20 00                     ICO: bits per pixel: 32      CUR: hotspot Y
A8 10 00 00               size of image data: 4264 bytes
16 00 00 00               offset of image data: 22
-- image data at offset 22 --
28 00 00 00               BITMAPINFOHEADER size: 40
20 00 00 00               width: 32
40 00 00 00               height: 64 (2 x 32: color bitmap + AND mask)
01 00 20 00               planes 1, 32 bits per pixel
00 00 00 00 ...           compression BI_RGB, then 32x32x4 pixel bytes and a 32x32 1-bit mask

ICONDIR#

Offset Size Field Value
0 2 Reserved 0
2 2 Type 1 = icon, 2 = cursor
4 2 Count number of images

ICONDIRENTRY#

Offset Size Field Meaning
0 1 Width pixels, 0 = 256
1 1 Height pixels, 0 = 256
2 1 ColorCount palette entries, 0 if more than 256 colors or no palette
3 1 Reserved 0
4 2 Planes / Hotspot X ICO: 0 or 1. CUR: hotspot X from the left
6 2 BitCount / Hotspot Y ICO: bits per pixel. CUR: hotspot Y from the top
8 4 BytesInRes size of the image data
12 4 ImageOffset offset of the image data from the start of the file

The directory values are hints. Decoders should trust the size and bit depth in the image data itself, because many tools write 0 for planes and bit count.

Image data: BMP or PNG#

Each entry’s data is one of 2 things:

The AND mask marks transparent pixels (1 = transparent) for 1-24 bpp images. 32 bpp entries carry an 8-bit alpha channel, and the mask is still present for old software.

Icons in EXE and DLL files#

Inside a Windows executable the icon is split into resources: one RT_GROUP_ICON resource holds the directory and each image is a separate RT_ICON resource. The group entry (GRPICONDIRENTRY) is 14 bytes: it has a 2-byte resource ID where the file format has the 4-byte offset. Tools that “extract icons” from an EXE rebuild an ICO file from these resources.

Sizes to include#

Use Sizes
Windows application icon 16, 24, 32, 48, 64, 256 (add 20, 40, 96 for exact high-DPI scaling)
favicon.ico 16, 32, 48
Cursor (.cur) 32 (add 48, 64, 96, 128 for high-DPI pointers)

Draw the small sizes by hand or at least sharpen them: a 256x256 icon scaled down to 16x16 is often blurry. Store 256x256 as PNG and the smaller sizes as 32-bit BMP for the best compatibility.

Specifications and documentation#

Software that opens ICO files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; shows the ICO image
Windows File Explorer and Photos✓viewbuilt into Windows; Explorer shows .ico and .cur files as their own thumbnails
Web browsers✓✓✓✓viewChrome, Edge, Firefox, Safari; used for favicon.ico. Also on Android and iOS
macOS Preview✓viewbuilt into macOS; shows every size in the sidebar
GIMP✓✓✓view, edit, create, convertfree, open source; each layer becomes one icon size on export
Greenfish Icon Editor Pro✓✓view, edit, create, convertfree icon and cursor editor
IcoFX✓view, edit, create, convertcommercial icon editor; extracts icons from EXE and DLL
IrfanView✓view, convertfree for non-commercial use
XnView MP✓✓✓view, convertfree for private use
ImageMagick✓✓✓convert, createcommand line, open source; magick in.png -define icon:auto-resize=256,48,32,16 out.ico
Photopea✓view, editfree, runs in the browser
RealFaviconGenerator✓createbuilds favicon.ico and PNG icons from one image

Libraries#

Open-source libraries that read and write ICO. See all ICO libraries for a comparison.

C/C++Magick++
C#ImageSharp, Magick.NET, System.Drawing.Icon
JavaTwelveMonkeys
Gogo-ico
PythonPillow
RubyMiniMagick
Rustico, image
PHPImagick