Palette Extractor
Drop in an image and get a palette of genuinely distinct colours, ready to copy as CSS custom properties, a Tailwind theme or JSON.
Runs entirely in your browser. Nothing is uploaded.
Drop an image here
JPEG, PNG, WebP or GIF, up to 25 MB
Processed in your browser. Nothing is uploaded.
About the Palette Extractor
Extracting a palette by counting the most frequent colours does not work on photographs. A picture of a beach is mostly sky, so the ten most common colours are ten nearly identical blues and the result is useless. What you want is a set of colours that are distinct from each other and that between them describe the image.
That is a clustering problem, and this tool solves it with k-means: group every pixel with the pixels it most resembles, then take the centre of each group. Ask for six colours and you get six groups, each genuinely different from the others, with the share of the image each one accounts for.
The detail that makes it work well is measuring distance in OKLab rather than RGB. RGB distance does not match how different two colours look — the green channel dominates it — so RGB clustering merges colours people see as distinct and splits ones they do not. Clustering in a perceptual space produces groups that match what the eye groups.
Starting positions are chosen with k-means++, which picks initial centres far apart rather than at random. Random seeding regularly drops two centres inside the same cluster, and the visible result is a palette with two nearly identical swatches in it.
All of this runs in a Web Worker, because clustering twenty thousand pixels is several million calculations and the main thread would visibly stall. Your image is never uploaded — it is read straight into a canvas in the tab and stays there.
Frequently asked questions
Why not just take the most common colours?
Because on a photo the most common colours are all nearly the same. A picture of a beach is mostly sky, so counting frequency returns ten similar blues. Clustering returns colours that are actually distinct from each other.
Is my image uploaded?
No. It is read into a canvas in your browser and the pixels are analysed there. Nothing is transmitted, which matters for photographs more than most files.
Why do results shift slightly between runs?
k-means starts from seeded positions, so the outcome can vary a little. The seeding here spreads the starting points deliberately, which keeps the variation small and prevents duplicate swatches.
You might also need
- Design & colour
Color Converter
Convert between HEX, RGB, HSL, OKLCH and CMYK, with a gamut-correct tint scale.
- Design & colour
Contrast Checker
Check any two colours against WCAG AA and AAA, and get the nearest colour that passes.
- Design & colour
Favicon Generator
Turn one image into every favicon size, a web manifest and the HTML to paste.