Color Thief is a JavaScript library that extracts dominant colors and color palettes from images in both browser and Node.js environments.
The library solves the problem of programmatically analyzing image color composition. It works by sampling pixels from an image, quantizing them into a palette using perceptually uniform color spaces, and returning semantic color swatches labeled by characteristics like Vibrant, Muted, DarkVibrant, and LightMuted. The tool offers both synchronous extraction for browser use and asynchronous APIs for Node.js, with a progressive three-pass refinement mode that delivers rough results instantly before refining them further. It includes rich Color objects that expose multiple output formats—hex, RGB, HSL, OKLCH—along with WCAG contrast ratios and automatic text color recommendations for accessibility.
Developers should choose this tool if they need client-side color extraction without server dependencies, particularly for interactive applications like image editors, theme generators, or dynamic UI styling. The library suits projects requiring both browser and Node.js support with a unified API. It distinguishes itself through perceptually uniform OKLCH quantization for more natural palettes, semantic swatch categorization, reactive observation of live video and canvas elements, and Web Worker compatibility via ImageBitmap and OffscreenCanvas. The CLI tool enables command-line extraction with JSON, CSS, and ANSI output. The project carries zero runtime dependencies and includes full TypeScript definitions.
Development activity shows consistent maintenance with regular updates addressing edge cases and feature refinement. The project demonstrates responsiveness to user-reported issues and maintains backward compatibility across releases. Documentation is thorough with clear API examples and detailed option descriptions. The codebase reflects attention to performance optimization, particularly in the progressive extraction and worker-friendly design patterns.