# icojs

> Decode and encode ICO files

Latest version **1.0.1** (published 2026-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install icojs
pnpm add icojs
yarn add icojs
bun add icojs
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2026-08-22 |
| First published | 2015-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.22.2 |
| Dependencies | 5 |
| Unpacked size | 112.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 59 |
| Author | egy186 |
| Maintainers | egy186 |
| Keywords | ico, decode, encode |

## Links

- npm: https://www.npmjs.com/package/icojs
- Repository: https://github.com/egy186/icojs
- Homepage: https://egy186.github.io/icojs
- Issues: https://github.com/egy186/icojs/issues
- npm.io page: https://npm.io/package/icojs

## Dependencies (5)

- [pngjs](https://npm.io/package/pngjs.md) ^7.0.0
- [bmp-ts](https://npm.io/package/bmp-ts.md) ^1.0.9
- [jpeg-js](https://npm.io/package/jpeg-js.md) ^0.4.4
- [file-type](https://npm.io/package/file-type.md) ^22.0.2
- [decode-ico](https://npm.io/package/decode-ico.md) ^0.4.1

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2026-08-22
- 1.0.0 — 2026-05-13
- 0.23.0 — 2026-04-22
- 0.22.1 — 2026-04-21
- 0.22.0 — 2026-04-18
- 0.21.1 — 2026-04-12
- 0.21.0 — 2026-04-11
- 0.20.2 — 2026-04-05
- 0.20.1 — 2025-11-04
- 0.20.0 — 2025-10-17
- 0.19.5 — 2025-02-07
- 0.19.4 — 2024-08-23
- 0.19.3 — 2023-12-17
- 0.19.2 — 2023-12-13
- 0.19.1 — 2023-12-02
- … 37 more at https://npm.io/package/icojs/versions

## README

# icojs

[![NPM Version](https://img.shields.io/npm/v/icojs)](https://www.npmjs.com/package/icojs)
[![CI](https://github.com/egy186/icojs/actions/workflows/ci.yml/badge.svg)](https://github.com/egy186/icojs/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/egy186/icojs/badge.svg?branch=main)](https://coveralls.io/github/egy186/icojs?branch=main)

A JavaScript library for decoding and encoding ICO files.
Works in both Node.js and the browser.

## Install

```sh
npm install icojs
```

```js
import { decodeIco, encodeIco, isIco } from 'icojs';
```

A UMD bundle is also available for browsers.

```html
<script src="node_modules/icojs/dist/ico.js"></script>
```

## Demo

* Decoder: [https://egy186.github.io/icojs/demo-decoder.html](https://egy186.github.io/icojs/demo-decoder.html)
* Encoder: [https://egy186.github.io/icojs/demo-encoder.html](https://egy186.github.io/icojs/demo-encoder.html)

## Example

### Decoding

Node.js:

```js
import { readFile, writeFile } from 'node:fs/promises';
import { decodeIco } from 'icojs';

const buffer = await readFile('favicon.ico');
const images = await decodeIco(buffer, 'image/png');
// save as png files
images.forEach(image => {
  const file = `${image.width}x${image.height}-${image.bpp}bit.png`;
  const data = Buffer.from(image.buffer);
  writeFile(file, data);
});
```

Browser:

```html
<input type="file" id="input-file" />
<script>
  document.querySelector('#input-file').addEventListener('change', async evt => {
    const file = evt.target.files[0];
    const buffer = await file.arrayBuffer();
    const images = await ICO.decodeIco(buffer);
    // logs images
    console.dir(images);
  });
</script>
```

### Encoding

Node.js:

```js
import { readFile, writeFile } from 'node:fs/promises';
import { encodeIco } from 'icojs';

const buffer1 = await readFile('16x16.png');
const buffer2 = await readFile('32x32.png');
const ico = await encodeIco([
  { buffer: buffer1 },
  { buffer: buffer2 }
]);
// save as a ico file
writeFile('favicon.ico', Buffer.from(ico));
```

Browser:

```html
<input type="file" id="input-file" multiple />
<script>
  document.querySelector('#input-file').addEventListener('change', async evt => {
    const files = Array.from(evt.target.files);
    const iconList = await Promise.all(files.map(async file => {
      const buffer = await file.arrayBuffer();
      return { buffer };
    }));
    const ico = await ICO.encodeIco(iconList);
    // logs ico
    console.dir(ico);
  });
</script>
```

## API Documentation

[https://egy186.github.io/icojs/](https://egy186.github.io/icojs/)

---
_Source: https://npm.io/package/icojs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
