What it does
Color Thief extracts dominant colours and palettes through JavaScript. It also follows video frames and returns swatches with text-colour suggestions.
Install colorthief and pass an image into a palette function. Set the colour count, sampling rate or crop region, then read hex, RGB or CSS values from the returned objects.
Lower quality numbers inspect more pixels and take longer. Current palettes use OKLCH by default, with RGB available as an alternative. Video observation supports throttled updates; stop its controller when finished.
Node processing needs the asynchronous functions and the Sharp dependency. Wide-gamut extraction is browser-only; Node output uses sRGB.
The MIT-licensed code can be incorporated into a product while retaining its notices.
Strengths
- Region controls isolate a relevant part of an image.
Watch out for
- Synchronous extraction accepts browser sources only.
Best for
- Image-driven interface colours
Sources
- Color Thief examples and API (Oct 27, 2026)
- Color Thief MIT licence (Oct 27, 2026)
