npm / chroma-js
chroma-js
What changed in chroma-js 2 to 3, from its official release notes, upgrade guides and advisories. Also covers @types/chroma-js. Sources checked 2026-10-29.
8 breaking5 new APIs and options3 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initchroma-js 39 changes
Breaking changes 3
The domain function now returns all scaled positions rather than only the minimum and maximum.
color.css() now returns modern space-separated CSS colors instead of legacy comma-separated syntax.
The hsl2rgb conversion no longer rounds.
New APIs and options 3
chroma.random accepts an rng argument, allowing callers to provide a random number generator.
CSS colors can now be exported and parsed in lab(), lch(), oklab(), and oklch() color spaces.
Sets the standard white reference point for the CIE Lab and CIE Lch color spaces.
Fixes and other changes 3
The scale.domain implementation was fixed.
Repairs non-default imports.
OKLab now uses the W3C implementation.
chroma-js 27 changes
Breaking changes 5
The default interpolation for average is now lrgb.
When colors cannot be parsed correctly, chroma now throws Errors instead of silently failing with console.errors.
HCG inputs now use [0..360,0..1,0..1] instead of [0..360,0..100,0..100], aligning with HSL.
The default interpolation for interpolate is now lrgb.
The default interpolation for mix is now lrgb.
New APIs and options 2
chroma.js was ported to ES6, allowing projects to import parts of chroma.
Color conversion functions support object unpacking, such as passing {h,s,l} to hsl2rgb.