v2.3.0MIT License

Color ThiefExtract colors from images

Grab the dominant color or a complete palette from any image using pure JavaScript. Works in browsers and Node.js with zero dependencies.

Extracted Colors

Colors automatically identified from the sample image

Sample image for color extraction

Dominant Color

Color Palette

10 colors

Color Thief automatically detects these colors, providing both the dominant color and a palette for your design needs.

Pure JS
No server

Why Choose Color Thief?

Extract beautiful color palettes from any image with pure JavaScript that works in both browsers and Node.js environments.

Simple API

Just two methods to learn: getColor() and getPalette(). Extract the dominant color or a complete palette with minimal code.

// Browser usage
const colorThief = new ColorThief();
const img = document.querySelector('img');

// Make sure image is loaded
if (img.complete) {
  const dominantColor = colorThief.getColor(img);
  const palette = colorThief.getPalette(img, 5);
} else {
  img.addEventListener('load', function() {
    const dominantColor = colorThief.getColor(img);
    const palette = colorThief.getPalette(img, 5);
  });
}
Works with any image format

Smart Color Extraction

Advanced algorithms identify the most prominent colors that best represent your image.

demo

Dominant Color

Color Palette

Lightning Fast

Optimized algorithms extract colors with minimal processing time, even on large images.

Fast

Works Everywhere

Use in browsers or Node.js environments with the same simple API.

Browser

Node.js

Open Source

MIT licensed and community approved with thousands of users worldwide.

9k+
GitHub Stars
1M+
Downloads

Zero Dependencies

Lightweight implementation with no external libraries required. Simply include and use.

~14kb minified

Frequently Asked Questions

Got questions about using Color Thief? We've got answers to help you get started quickly.

Still have questions?

If your issue is unique, post a new question on Stack Overflow or check out our GitHub repository.

Ready to extract colors from your images?

Get started with Color Thief in minutes. Super lightweight, zero dependencies, and works in both browser and Node.js environments.

Zero dependencies
Browser & Node.js
MIT License
npm install --save colorthief

Quick Usage

Browser
const colorThief = new ColorThief();
const img = document.querySelector('img');

// Wait for image to load
img.addEventListener('load', function() {
  const dominantColor = colorThief.getColor(img);
  const palette = colorThief.getPalette(img, 5);
  console.log(dominantColor, palette);
});
9k+
GitHub Stars
300k+
Monthly Downloads
2.3.0
Current Version
MIT
License

Join thousands of developers already using Color Thief to create beautiful, dynamic interfaces that respond to image content.