# rgb-hex

> Convert RGB(A) color to HEX

Latest version **4.1.0** (published 2023-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install rgb-hex
pnpm add rgb-hex
yarn add rgb-hex
bun add rgb-hex
```

## Health

**Score 30/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2023-09-01 |
| First published | 2014-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 121 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | rgb, hex, color, colour, convert, conversion, converter |

## Links

- npm: https://www.npmjs.com/package/rgb-hex
- Repository: https://github.com/sindresorhus/rgb-hex
- Homepage: https://github.com/sindresorhus/rgb-hex#readme
- Issues: https://github.com/sindresorhus/rgb-hex/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/rgb-hex

## 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

- 4.1.0 (latest) — 2023-09-01
- 4.0.1 — 2023-03-14
- 4.0.0 — 2021-05-03
- 3.0.0 — 2019-04-26
- 2.1.0 — 2016-11-04
- 2.0.0 — 2016-08-14
- 1.0.0 — 2014-07-27

## README

# rgb-hex

> Convert RGB(A) color to HEX

## Install

```
$ npm install rgb-hex
```

## Usage

```js
import rgbHex from 'rgb-hex';

rgbHex(65, 131, 196);
//=> '4183c4'

rgbHex('rgb(40, 42, 54)');
//=> '282a36'

rgbHex(65, 131, 196, 0.2);
//=> '4183c433'

rgbHex(40, 42, 54, '75%');
//=> '282a36bf'

rgbHex('rgba(40, 42, 54, 75%)');
//=> '282a36bf'
```

## Related

- [rgb-hex-cli](https://github.com/sindresorhus/rgb-hex-cli) - CLI for this module
- [hex-rgb](https://github.com/sindresorhus/hex-rgb) - Convert HEX color to RGB

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