ColorSwatches.org

Image Color Palette Extractor

Upload any image to extract its dominant colors. Adjust the number of colors anytime without re-uploading. Everything runs in your browser — no data is sent to any server.

Drag & drop an image here

or click to browse — JPG, PNG, GIF, WebP supported

About the Image Color Palette Extractor

This tool analyzes the pixels of any image you provide and identifies the most visually significant colors using a k-means clustering algorithm. Rather than simply finding the most frequently occurring pixel values — which often returns near-identical shades — k-means groups similar colors together and returns a representative centroid for each group, giving you a more visually distinct and useful palette.

How to Use It

  1. Upload an image by dragging it onto the drop zone or clicking Browse File. JPG, PNG, GIF, and WebP are all supported.
  2. Choose the number of colors (2–10) you want in your palette using the selector. The palette updates instantly — no need to re-upload.
  3. Click any swatch to copy its hex code to your clipboard.

How the Algorithm Works

The extraction process works in three stages:

  1. Sampling — Rather than processing every pixel (which would be slow), the tool samples a representative subset of pixels from the image, skipping transparent pixels.
  2. K-means clustering — Pixels are grouped into k clusters (where k is the number of colors you selected). Each cluster is initialized with a randomly chosen pixel, then iteratively refined: every pixel is assigned to the nearest cluster centroid, and centroids are recalculated as the average of their assigned pixels. This repeats until centroids stabilize.
  3. Sorting — The resulting colors are sorted by perceived luminance so lighter colors appear first.

Tips for Better Results

  • Images with distinct color regions (like landscapes or illustrated posters) produce cleaner palettes than photographs with complex gradients.
  • For brand color extraction, try using a logo or product shot with a plain background.
  • If the palette looks washed out, try reducing the number of colors — fewer clusters means each centroid is a stronger representative.
  • Very small images (under ~100×100 px) may produce less accurate results due to limited pixel samples.

Frequently Asked Questions

Is my image uploaded to a server?

No. Your image never leaves your device. The entire extraction process runs in your browser using the HTML5 Canvas API. Nothing is transmitted to any server.

What image formats are supported?

Any image format your browser can display: JPEG, PNG, GIF, WebP, AVIF, BMP, and SVG.

Why do the colors sometimes look different from what I see in the image?

K-means returns the mathematical average color for each cluster. In areas of the image where many similar-but-distinct colors are blended (like a sunset gradient), the centroid may be a color that never literally appeared as a single pixel. This is intentional — it gives you a more representative palette rather than an arbitrary pixel sample.

Can I use the extracted colors in my design tools?

Yes. Click any swatch to copy its hex code. Hex codes paste directly into most design tools including Figma, Sketch, Adobe XD, Photoshop, and CSS.

Why does changing the color count sometimes give very different results?

K-means has some randomness in its initialization — different runs can converge to slightly different solutions. Additionally, more colors means each cluster covers a smaller portion of color space, so rarer colors that were previously grouped into a large cluster may now appear as their own swatch.

Is there a maximum image size?

There is no hard limit, but very large images (above ~10 MB) may take a moment to process. The tool automatically subsamples pixels for performance, so even large images finish quickly in most browsers.

More Color Tools

Browse all tools →