# color-alpha

> Change alpha value of a color string

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

## Install

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

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2026-07-22 |
| First published | 2016-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Dmitry Iv. |
| Maintainers | dfcreative, dy |
| Keywords | color, alpha, opacity, css, css-color, color-space, color-parse, color-manipulate, channel |

## Links

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

## Dependencies (1)

- [color-parse](https://npm.io/package/color-parse.md) ^2.1.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2026-07-22
- 2.1.0 — 2026-07-22
- 2.0.0 — 2024-03-14
- 1.1.3 — 2021-06-13
- 1.1.2 — 2020-10-02
- 1.1.1 — 2020-09-26
- 1.1.0 — 2020-09-26
- 1.0.4 — 2019-05-25
- 1.0.3 — 2018-04-27
- 1.0.2 — 2016-10-05
- 1.0.1 — 2016-08-16
- 1.0.0 — 2016-08-16

## README

# color-alpha [![test](https://github.com/colorjs/color-alpha/actions/workflows/test.js.yml/badge.svg)](https://github.com/colorjs/color-alpha/actions/workflows/test.js.yml) [![size](https://img.shields.io/bundlephobia/minzip/color-alpha?label=size)](https://bundlephobia.com/result?p=color-alpha) ![stable](https://img.shields.io/badge/stability-stable-green)

Change alpha of a color.

`$ npm install color-alpha`

```js
import α from 'color-alpha'
α('white', .4); // 'rgba(255,255,255, 0.4)'
α('oklch(0.628 0.258 29.234)', .3); // 'oklch(0.628 0.258 29.234 / 0.3)'
α('rgba(244, 244, 244, .3)'); // 'rgba(244,244,244, 0.3)' — no alpha reads the color's own
```

Input color is parsed with [color-parse](https://ghub.io/color-parse): legacy `rgb`/`hsl` keep comma syntax, modern spaces (`lab`, `oklch`, `color(display-p3 …)` etc.) serialize with css slash syntax. Unparseable input returns `undefined`.

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