# color-normalize

> Convert any color data to sanitized output format

Latest version **2.1.1** (published 2026-07-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2026-07-22 |
| First published | 2017-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Dmitry Yv |
| Maintainers | dfcreative, zeke, dy |
| Keywords | color, colorjs, rgb, rgba, color-space, css |

## Links

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

## Dependencies (2)

- [dtype](https://npm.io/package/dtype.md) ^2.0.0
- [color-rgba](https://npm.io/package/color-rgba.md) ^3.1.0

## 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.1.1 (latest) — 2026-07-22
- 2.1.0 — 2026-07-22
- 2.0.0 — 2024-03-14
- 1.5.2 — 2020-10-02
- 1.5.1 — 2020-09-26
- 1.5.0 — 2019-07-02
- 1.4.0 — 2019-06-26
- 1.1.1 — 2019-06-25
- 1.3.0 — 2018-07-26
- 1.2.0 — 2018-07-25
- 1.1.0 — 2018-06-22
- 1.0.3 — 2018-01-15
- 1.0.2 — 2018-01-11
- 1.0.1 — 2017-10-24
- 1.0.0 — 2017-10-24

## README

# color-normalize [![test](https://github.com/colorjs/color-normalize/actions/workflows/test.js.yml/badge.svg)](https://github.com/colorjs/color-normalize/actions/workflows/test.js.yml) [![size](https://img.shields.io/bundlephobia/minzip/color-normalize?label=size)](https://bundlephobia.com/result?p=color-normalize) ![stable](https://img.shields.io/badge/stability-stable-green)

Convert any color argument (string, color, number, object etc.) to an array with channels data of desired output format.


## Usage

`$ npm install color-normalize`

```js
import rgba from 'color-normalize'

rgba('red') // [1, 0, 0, 1]
rgba('rgb(80, 120, 160)', 'uint8') // Uint8Array<[80, 120, 160, 255]>
rgba('rgba(255, 255, 255, .5)', 'float64') // Float64Array<[1, 1, 1, .5]>
rgba('hsla(109, 50%, 50%, .75)', 'uint8') // Uint8Array<[87, 191, 63, 191]>
rgba(new Float32Array([0, 0.25, 0, 1]), 'uint8_clamped') // Uint8ClampedArray<[0, 63, 0, 255]>
rgba(new Uint8Array([0, 72, 0, 255]), 'array') // [0, 0.2823529411764706, 0, 1]

// ambivalent input
rgba([0,0,0]) // [0,0,0,1]
rgba([.5,.5,.5]) // [.5,.5,.5,1]
rgba([1,1,1]) // [1,1,1,1]
rgba([127.5,127.5,127.5]) // [.5,.5,.5,1]
rgba([255,255,255]) // [1,1,1,1]
```

Output format can be any [dtype](https://npmjs.org/package/dtype): `uint8`, `uint8_clamped`, `array`, `float32`, `float64` etc. By default it converts to `array` with `0..1` range values.


## Related

* [color-alpha](https://github.com/colorjs/color-alpha) − change alpha of a color string.
* [color-interpolate](https://github.com/colorjs/color-interpolate) − interpolate by color palette.
* [color-parse](https://github.com/colorjs/color-parse) − comprehensive color string parser.
* [color-rgba](https://github.com/colorjs/color-rgba) − get rgba channel values from a string.
* [flatten-vertex-data](https://npmjs.org/package/flatten-vertex-data) − ensure sequence of point coordinates is flat.

## License

(c) 2017 Dmitry Iv. MIT License

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