# color-id

> Pack RGBA color channels into uint32 and back

Latest version **2.0.0** (published 2026-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install color-id
pnpm add color-id
yarn add color-id
bun add color-id
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-03-27 |
| First published | 2017-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dmitry Iv. |
| Maintainers | dfcreative, dy |
| Keywords | color, rgba, pack, uint32, colorjs |

## Links

- npm: https://www.npmjs.com/package/color-id
- Repository: https://github.com/colorjs/color-id
- Homepage: https://github.com/colorjs/color-id#readme
- Issues: https://github.com/colorjs/color-id/issues
- npm.io page: https://npm.io/package/color-id

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-03-27
- 1.1.0 — 2017-06-05
- 1.0.3 — 2017-02-15
- 1.0.2 — 2017-02-11
- 1.0.1 — 2017-02-08
- 1.0.0 — 2017-02-08

## README

# color-id

Pack RGBA color channels into a single uint32 integer and back.

## Install

```
npm install color-id
```

## Usage

```js
import colorId, { from } from 'color-id'

// normalized 0..1 (default)
colorId([1, 0, 0, 1])     // 0xff0000ff
from(0xff0000ff)           // [1, 0, 0, 1]

// byte values 0..255
colorId([255, 0, 0, 255], false)  // 0xff0000ff
from(0xff0000ff, false)           // [255, 0, 0, 255]
```

## API

### `coloId(rgba, normalized=true)` / default export

Pack `[r, g, b, a?]` channels into a uint32. Values are clamped to valid range. Alpha defaults to `1` (normalized) or `255` (byte).

### `from(n, normalized=true)`

Unpack uint32 into `[r, g, b, a]` channels.

**`normalized`** — `true` for 0..1 range, `false` for 0..255 byte values.

## Related

- [color-rgba](https://github.com/colorjs/color-rgba) — parse color string to rgba array
- [color-alpha](https://github.com/colorjs/color-alpha) — change alpha channel for a color
- [color-interpolate](https://github.com/colorjs/color-interpolate) — interpolate over palette or gradient

## License

MIT

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