File format · .icns
ICO File Format Reference and Repair Guide
Deep reference on the Windows ICO icon resource file format: its multi-image structure, how ICO files become corrupt, and how damaged icons can be repaired.
An ICO file is a container for one or more small bitmap images used as icons by Microsoft Windows. Every Windows executable that displays an icon—on the desktop, in the Start menu, in the taskbar, or in File Explorer—must embed that icon in ICO format. Because a single ICO file typically holds the same picture at several sizes and color depths, Windows can choose the best-fitting variant for the current display mode and scaling factor. This page covers the ICO format's structure, the closely related CUR and ANI cursor formats, the common causes of corruption, and what is typically recoverable when an icon file goes wrong.
What the ICO format is and where it is used
ICO is the native icon-image format for the Windows operating system. It is not a single-image format like PNG or JPEG; rather, it is a directory of images bundled into one file so that the operating system can select an appropriate size and color depth on the fly. Windows requires ICO resources for application icons, shortcut overlays, and many shell-display scenarios.
Two sibling formats share ICO's internal design:
- CUR — the Windows cursor format. It is nearly identical to ICO, differing only in the identifying bytes in the header and the addition of a hotspot value: the x/y pixel offset from the top-left corner of the image to the point that actually registers as the pointer location.
- ANI — the animated cursor format. ANI is built on the RIFF container, and each animation frame is itself a complete CUR-format image that may contain multiple sizes and depths.
ICO files also see limited use on the web. Browsers have long supported ICO as a website favicon format for legacy reasons, though modern browsers generally prefer PNG, SVG, or WebP. Some browser-specific features of the format (such as screen pixel inversion for cursors) were never implemented on the web.
Structure and key technical facts
Historical evolution
The format has evolved substantially across Windows versions:
- Windows 1.0–2.x: Icons were monochrome raw bitmaps with no directory wrapper. A standalone icon file contained a single image—64×64 for icons, 32×32 for cursors. Applications could load icons only from resources compiled into their own executable module (via
LoadIconandLoadCursor); loading a standalone.icofile directly was not yet supported. - Windows 3.0: Introduced the multi-image ICONDIR wrapper and DIB-based frame layout. The 40-byte
BITMAPINFOHEADERbecame the norm, though rare early samples used the 12-byte OS/2 Presentation ManagerBITMAPCOREHEADER. Shipping icons of this era used 1 bpp (monochrome) and 4 bpp (16-color VGA), typically pairing both depths in one file; 8 bpp was not yet common. - Windows 95: Extended the directory to describe images from 1×1 up to 256×256 pixels (a width or height byte of 0 is interpreted as 256) and added 32 bpp color depth (16.7 million colors) alongside the existing 1, 4, and 8 bpp modes. Non-square sizes are permitted by the format.
Internal layout
A modern ICO file is organized as:
- ICONDIR (file header): A 6-byte structure containing a reserved word (always 0), a type word (1 for ICO, 2 for CUR), and a count of images in the file.
- ICONDIRENTRY array: One entry per image, each 16 bytes. Each entry records the pixel dimensions (width and height, with 0 meaning 256), the color count (0 for 256 or more), reserved bytes, the hotspot coordinates (CUR only), the size of the image data in bytes, and the byte offset of that image data within the file.
- Image data: Each image is stored as a device-independent bitmap (DIB). In modern files the DIB typically uses a
BITMAPINFOHEADERfollowed by color table, XOR mask, and AND mask. Some newer ICO files embed a PNG-encoded image directly as the data payload for the 256×256 (or high-resolution) variant, which is a widely supported optimization.
Because the directory stores explicit offsets and sizes for each image, an ICO file can be parsed without scanning for internal markers. Conversely, if those offset or size fields are wrong, the corresponding image may fail to load even though the bitmap data itself is intact.
Why ICO and CUR files become corrupt or unreadable
ICO files are small and structurally simple, which makes most of the failure modes straightforward:
- Truncated downloads or transfers: Because the format relies on byte offsets recorded in the directory, a file cut short by even a few bytes can leave one or more images pointing past the end of the file.
- Incorrect editing or batch conversion: Tools that resize, re-depth, or convert between ICO, CUR, PNG, and BMP can write a directory entry whose width, height, color depth, or data-size field does not match the actual bitmap payload. The result is an icon that renders blank, at the wrong size, or not at all.
- Executable resource corruption: Most icons in the wild live inside
.exe,.dll, or.iclfiles as compiled resources. A damaged executable header, a partially overwritten resource section, or a failed resource update can leave the embedded ICO resource unreadable even when the rest of the program is fine. - Favicon extraction errors: ICO files scraped from websites are sometimes misidentified, re-saved with the wrong extension, or wrapped in a container the extracting tool did not understand.
- Classic Mac OS resource forks: On classic Mac OS, icon bitmaps were stored in the resource fork of a file rather than the data fork. When such files are moved through non-Mac-aware channels (or stripped of their resource fork on modern macOS), the icon data can be lost entirely. We frequently see this in cross-platform archives and legacy file migrations.
- ANI / RIFF container damage: Animated cursors depend on a valid RIFF chunk structure. A broken chunk size, missing
anihheader, or malformed frame list can prevent the animation from playing or cause the cursor to load only its first frame.
What data can be recovered
Recovery prospects for ICO files are generally good because the format stores each image independently. Common outcomes include:
- Intact images extracted from a partially corrupt file: If the directory is damaged but the bitmap data survives, individual images can often be located by signature scanning and rebuilt into a valid ICO or exported as PNG/BMP.
- Reconstruction of the ICONDIR: When only the header or directory entries are wrong, we can recompute the correct offsets, sizes, and dimension fields from the actual image payloads and write a new, valid directory.
- Extraction from damaged executables: Icons compiled into a corrupt
.exeor.dllcan frequently be recovered by parsing the PE resource section directly, bypassing the damaged parts of the executable. - Recovery of classic Mac resource-fork icons: If the resource fork is preserved (for example, in a
.sitarchive, a BinHex file, or an AppleDouble pair), the icon resources can be extracted and converted. If the fork has been stripped, recovery depends on whether a copy survives elsewhere. - Frame salvage from ANI files: Even when an animated cursor's RIFF container is damaged, individual CUR frames can often be recovered and reassembled into a new animation or exported as static cursors.
In cases where the bitmap payload itself has been overwritten or is missing, the affected image cannot be recovered—but other sizes or depths in the same file are usually unaffected and can still be salvaged.
How recovery works
Our recovery process for ICO and related formats follows a consistent sequence:
- Structural analysis. We parse the ICONDIR and ICONDIRENTRY array, checking that each image's recorded offset and size fall within the file and that the dimension and depth fields are consistent with the payload that actually follows.
- Signature and payload scan. For files with a damaged directory, we scan the raw bytes for
BITMAPINFOHEADERsignatures and PNG signatures, identifying image boundaries directly from the data. - Validation of each image. Every candidate image is decoded to confirm that the color table, XOR mask, and AND mask are internally consistent and that the declared dimensions match the actual pixel data.
- Rebuild or export. We either reconstruct a valid ICO/CUR file with corrected directory entries or export the recoverable images to PNG, BMP, or individual ICO files, depending on what the customer needs.
- Executable and container recovery. When the icon is embedded in a program or library, we parse the PE resource directory (or the RIFF structure for ANI) to locate and extract the icon resource without relying on the host file's higher-level integrity.
For classic Mac OS files, we additionally inspect both forks and, where necessary, reconstruct or convert the resource-fork icon data into a modern format.
FAQ
What is the difference between ICO and CUR?
The two formats are almost identical internally. ICO is for icons; CUR is for cursors. CUR adds a hotspot—the x/y pixel offset that marks the true pointer position—and uses a different type identifier in the header.
Can a corrupt ICO file be fixed if the header is damaged?
Usually yes. The directory and header are small and can often be reconstructed from the image data that follows, provided the bitmap payloads themselves are intact.
Why does my icon show up blank or at the wrong size?
This typically means an ICONDIRENTRY field—width, height, color depth, or data size—does not match the actual image payload. The shell reads the directory first and may render nothing or a distorted image if those fields are wrong.
Are icons inside EXE and DLL files recoverable if the program is damaged?
In most cases, yes. Icons are stored in the PE resource section, which can be parsed independently of the executable's code and other data. We can usually extract the icon resources even from a partially corrupt binary.
What is the largest icon size supported by ICO?
The Windows 95 extension to the format allows images up to 256×256 pixels (encoded as a dimension value of 0 in the directory entry). Modern ICO files often store this large variant as a PNG payload to reduce file size.
Can animated ANI cursors be repaired?
Often, yes. ANI is a RIFF container of CUR frames. If the container is damaged, we can usually recover the individual frames and either rebuild the animation or supply them as static cursors.
If you have a corrupt, unreadable, or misbehaving ICO, CUR, or ANI file—or an executable whose icon resources will not load—send it to us for a free evaluation. We will assess the damage, identify exactly which images can be recovered, and provide a clear plan before any paid work begins.
Send us your .icns file for a free evaluation
Our recovery engineers will tell you exactly what can be recovered — at no cost. There is no charge if we cannot recover your data.
Start a free evaluation