Color Palette Extractor Online Free

🎨 Image Design ✔ Free Forever

Color Palette Extractor Online Free

Upload any image and instantly extract its dominant color palette. Get HEX, RGB, and HSL values for every color. Copy any value with one click. No signup, no install.

✔ HEX, RGB, HSL output ✔ Up to 20 colors ✔ Download palette as PNG ✔ Works offline ✔ No data uploaded
🖼
Drop your image here
PNG, JPG, WEBP, GIF, BMP, SVG supported
Choose Image
Extracting colors…
Uploaded image preview
Color Palette
Number of Colors
10
Color Format
Sort Order
Export Palette
🔒 Your image never leaves your device. All processing happens in your browser.
About This Tool

Finding the dominant colors with k-means clustering

Extracting a palette from a photo isn’t as simple as counting unique pixel values, most photos contain tens of thousands of near duplicate colors thanks to compression noise and gradients. This tool solves it with k-means clustering, the same general purpose clustering algorithm used across data science, applied here to points in three dimensional RGB space instead of a spreadsheet of numbers. It runs entirely as plain JavaScript over canvas pixel data, no upload, no external color API.

How the clustering actually runs

Step 1 Downscale and sample The image is first drawn to a canvas capped at 400px on the long edge, then further subsampled so at most roughly 4000 pixels are analyzed. Fully transparent pixels (alpha under 128) are skipped entirely so they can’t skew the palette toward background transparency.
Step 2 Seed the centers Instead of random initialization, the tool seeds each of the k cluster centers by picking evenly spaced samples across the pixel list, a simple but effective way to spread starting points across the image’s actual color range.
Step 3 Assign and update For 12 iterations, every sampled pixel is assigned to its nearest center by Euclidean distance in RGB space, then each center is recomputed as the average of every pixel assigned to it. This is the classic Lloyd’s algorithm loop.
Step 4 Count and report After convergence, a final pass counts how many sampled pixels landed closest to each center, giving each resulting color a frequency count that drives both its displayed percentage and the default sort order.
// the assignment step of k-means, from the tool source for (var pi = 0; pi < sample.length; pi++) { var p = sample[pi]; var best = 0, bestD = Infinity; for (var ci = 0; ci < centers.length; ci++) { var d = colorDist(p, centers[ci]); if (d < bestD) { bestD = d; best = ci; } } clusters[best].sum[0] += p[0]; clusters[best].sum[1] += p[1]; clusters[best].sum[2] += p[2]; clusters[best].count++; }

That distance function, Math.sqrt(dr*dr + dg*dg + db*db), is straight Euclidean distance in RGB space. It’s not perceptually uniform, two colors a fixed distance apart in RGB don’t necessarily look equally different to a human eye, but it’s fast and it produces genuinely representative dominant colors for a general-purpose extractor.

Sort modes and what they’re computing

SortBasis
FrequencyPixel count assigned to each cluster, descending
Luminance0.299R + 0.587G + 0.114B, brightest first
HueHSL hue angle, ascending around the color wheel
SaturationHSL saturation, most vivid first
The color count slider re-runs clustering from scratch. Moving from 6 to 10 colors doesn’t just split existing clusters, it reseeds all k centers and reruns the full 12-iteration loop, so colors that appeared at one count can shift slightly at another. This is expected: k-means results are a function of k, not a strict refinement of the previous result.
Format tabs

Every extracted color can be viewed as HEX, RGB, or HSL, all derived from the same underlying cluster center, formatting only, no re-extraction happens when you switch tabs.

PNG export

Draws each swatch as a labeled rectangle onto a new canvas and exports it as a downloadable strip image, useful for dropping a palette reference straight into a design file.

CSS and JSON export

CSS export writes a :root block with numbered custom properties; JSON export serializes each color’s index, hex, RGB object, and HSL string for use in a design token pipeline.

k-means clustering, client-side JS Adjustable color count, 2-20 PNG, CSS, JSON, TXT export

Where an extracted palette helps

Pulling a brand consistent color palette from a client’s logo or product photo, generating CSS custom properties directly from a mood board image, checking what colors actually dominate a photo before building a matching UI theme, or exporting a JSON token file from a photograph to feed into a design system pipeline. Photographers and designers also use extractors like this to quickly caption or tag images by their dominant color family.

Common Questions

FAQ: Color Palette Extractor Online Free

Yes, completely free. No account, no signup, no watermark, and no payment at any point. The tool works entirely in your browser.

The tool uses a k-means clustering algorithm running entirely in JavaScript. It samples pixel data from your image, groups similar colors into clusters, and returns the center color of each cluster as a dominant color. This approach gives you perceptually distinct colors rather than raw pixel values.

No. Everything runs locally in your browser using the HTML5 Canvas API and the FileReader API. Your image is read into memory and processed on your device. Nothing is sent to any server.

The tool accepts PNG, JPG, WEBP, GIF, BMP, and SVG files. Any format your browser can render as an image element will work. Large images are automatically downsampled before processing to keep it fast.

Sorting by frequency shows the most common colors first. This is useful for finding the dominant mood of the image. Sorting by brightness orders colors from lightest to darkest, which is helpful when building a tonal scale. Sorting by hue arranges colors around the color wheel, and sorting by saturation puts the most vivid colors first.

Click Export as CSS Variables. The tool copies a :root block with each color as –color-1, –color-2, and so on. Paste it at the top of your stylesheet and reference the variables anywhere in your CSS.

K-means clustering returns the average center of a color cluster, not an exact pixel color. The result is a representative dominant color for a group of similar pixels. You can increase the color count to get more specific clusters, or reduce it for a broader, more simplified palette.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.