Color Palette from Image

Extract dominant colors from any image. Get hex codes and CSS variables instantly.

Colors6
Upload an image to extract its palette

What Is a Color Palette Extractor?

A color palette extractor analyzes the pixels of an image and identifies its most prominent colors. The result is a small set of representative hex codes โ€” the dominant color palette of that image.

How It Works

The tool uses the k-means clustering algorithm directly in your browser:

  1. The image is downsampled to a working resolution for speed.
  2. Pixels are sampled and grouped into k clusters by color similarity.
  3. Each cluster centroid becomes one palette color.
  4. Colors are sorted by dominance โ€” the most frequent color appears first.

No libraries are used. The algorithm runs entirely in JavaScript via the Canvas API.

Common Use Cases

  • UI design โ€” match interface colors to a hero image or product photo
  • Brand identity โ€” extract a palette from a logo or mood board
  • Web development โ€” generate CSS custom properties from an image
  • Art & illustration โ€” analyze color harmony in reference images
  • Social media โ€” create consistent visual themes for feeds

How to Use

  1. Drop an image onto the upload zone or click to select a file.
  2. Choose how many colors to extract (2โ€“12).
  3. Click Extract palette.
  4. Click any color row to copy its hex code.
  5. Click Copy CSS variables to get all colors as :root { --palette-1: โ€ฆ }.

Frequently Asked Questions

What image formats are supported?

Any format your browser can decode: PNG, JPEG, WEBP, GIF, AVIF, and most others.

Why do results vary slightly between runs?

K-means uses a random initialization step. The final palette is usually stable, but for images with many similar colors, minor variation between runs is normal.

How many colors should I choose?

6 is a good default for most images. Use fewer (3โ€“4) for simple graphics or logos, more (8โ€“12) for rich photographs with complex color distributions.

Can I use the extracted hex codes directly in CSS?

Yes. Use the Copy CSS variables button to get a ready-to-paste :root {} block with --palette-1 through --palette-N variables.