chroma.js

gka.github.io ↗

Convert colours and generate data scales through a JavaScript API.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Yes AI reading, not confirmed
Sign-up required
Not confirmed

Ask SI about chroma.js

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the chroma.js homepage

What it does

chroma.js is a JavaScript library for colour conversion, manipulation and scales. It reads several colour formats and provides functions for interpolation, lightness adjustment and formatted output.

Install chroma-js and import the library. A colour can then pass through transformations such as darkening or saturation adjustment before being returned as a hex value.

For a chart, build a scale from chosen colours and set its numeric domain to match the data. Choose an interpolation space such as RGB, Lab or LCh; that choice affects the colours between the endpoints. Gamma shifts the scale’s centre, while lightness correction helps distribute brightness more evenly.

Some conversions produce colours outside the RGB range. The clipped() check identifies when channel values have been limited, which is useful when preserving a strong brand colour matters.

The library uses a BSD licence requiring retained notices. Its bundled ColorBrewer colours carry separate Apache 2.0 terms.

Strengths

  • A browser build and npm package support different project setups.

Watch out for

  • Changing interpolation space can noticeably change intermediate colours.

Best for

  • Developers generating colours from chart values or design parameters

Sources