# color-parse

> Color string parser

Latest version **2.1.2** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2026-07-28 |
| First published | 2015-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | Dmitry Ivanov |
| Maintainers | dfcreative, dy |
| Keywords | color, parse, color-parse, color-string, parse-color, css color |

## Links

- npm: https://www.npmjs.com/package/color-parse
- Repository: https://github.com/colorjs/color-parse
- Issues: https://github.com/colorjs/color-parse/issues
- npm.io page: https://npm.io/package/color-parse

## Dependencies (1)

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

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.1.2 (latest) — 2026-07-28
- 2.1.1 — 2026-07-22
- 2.1.0 — 2026-07-22
- 2.0.2 — 2024-03-15
- 2.0.1 — 2024-03-14
- 2.0.0 — 2023-09-15
- 1.4.3 — 2023-08-22
- 1.4.2 — 2020-10-02
- 1.4.1 — 2020-09-26
- 1.4.0 — 2020-09-26
- 1.3.8 — 2019-05-25
- 1.3.7 — 2018-06-22
- 1.3.6 — 2018-06-22
- 1.3.5 — 2017-10-24
- 1.3.4 — 2017-07-26
- … 15 more at https://npm.io/package/color-parse/versions

## README

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

Fast and compact color string parser.

`$ npm install color-parse`

```js
import parse from 'color-parse'

parse('hsla(12 10% 50% / .3)')
// { space: 'hsl', values: [12, 10, 50], alpha: 0.3 }
```

## Parsed strings

* [x] Color keywords: `red`, `green` etc., see [color-name](https://ghub.io/color-name)
* [x] `#RGB[A]`
* [x] `#RRGGBB[AA]`
* [x] `rgb[a](R, G, B[, A])`
* [x] `rgb(R G B[ / A])`
* [x] `hsl[a](H, S, L[, A])`, inc. [named hues](http://dev.w3.org/csswg/css-color/#simple-hues)
* [x] `hsl(H S L [ / A])`
* [x] `hwb(H, W, B)`
* [x] `cmyk(C, M, Y, K)`
* [x] `xyz(X, Y, Z)`
* [x] `luv(L, U, V)`
* [x] `luv(L U V[ / A])`
* [x] `lab(L, A, B)`
* [x] `lab(L a b[ / A])` - see [limits](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab)
* [x] `lch(L, C, H)`
* [x] `lch(L C H[ / A])` - see [limits](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch)
* [x] `oklab(L a b[ / A])` - see [limits](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab)
* [x] `oklch(L C H[ / A])` - see [limits](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch)
* [x] `color(space c1 c2 c3[ / A])`
* [x] `R:10 G:20 B:30[ A:0.5]`, decimals and negatives included
* [x] `L 0.39 C 0.083 H 153`
* [x] `(R10 / G20 / B30)`
* [x] `C100/M80/Y0/K35`
* [x] `[10, 20, 20]` as RGB
* [x] `10,20,20[,0.5]` as RGB[A]
* [x] `0x00ff00`, `0x0000ff` numbers as RGB

## Not parsed

* [x] unknown strings eg. `'yellowblue'`
* [x] malformed hex eg. `#zzz`, `#12345`
* [x] not strings: object, arrays etc.

## Related

* [color-space](https://npmjs.org/package/color-space) — collection of color space conversions.
* [color-rgba](https://npmjs.org/package/color-rgba) — convert any color string to rgba array.
* [color-alpha](https://npmjs.org/package/color-alpha) — change alpha component of any color.

## Analogs

* [parse-color](http://npmjs.org/package/parse-color) — parser by @substack. Performs calculations to every possible space, which bloats size.
* [color-parser](http://npmjs.org/package/color-parser) — parser by @tjholowaychuk. Supports limited set of spaces.
* [color-string](http://npmjs.org/package/color-string) — parsing/serializing module by Heather Arthur. Has extensive API for parsing and serializing from any to any space.

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