To get a colour palette from an image, a palette tool groups the image’s pixels into clusters of similar colour, usually with k-means clustering, and reports the average colour of each cluster and how much of the image it covers. Three to five colours give a tight, brand-style palette; eight to twelve capture more detail. The colour palette from image tool does this in your browser, adds an eyedropper for exact colours, and checks every swatch for text contrast.
Key takeaways
- The most common colours in a photo are often its backgrounds and shadows, not its accents. Use an eyedropper for small, vivid details.
- Grouping colours in a perceptual space such as OKLab gives palettes that match what you see.
- Check each colour’s contrast before deciding which ones can carry text.
- Export as CSS custom properties, then build tints and shades from your key colours.
How does a colour palette extractor work?
A photo can contain tens of thousands of distinct colours. A palette tool reduces them to a handful in four steps:
- Sample the pixels. Large images are scaled down first; a few thousand pixels describe the colours just as well as millions.
- Convert to a perceptual colour space. Refract uses OKLab, where equal distances look like equal differences to the eye. In plain RGB, two blues that look almost identical can be numerically far apart.
- Cluster with k-means. The algorithm places k centres, assigns every pixel to the nearest one, moves each centre to the average of its pixels, and repeats until nothing changes much.
- Report the results. Each centre becomes a swatch, and its share of pixels becomes the coverage percentage.
Refract starts the clustering from a fixed point, so the same image and settings always give the same palette, which matters when you need to recreate it later.
Why doesn’t the palette include the colour I wanted?
Because k-means rewards area. A product photo on a white background will report white, grey and a few shades of the product; the small orange logo on the box might not make the list at all. Three ways to get it:
- Increase the number of colours so smaller areas get their own cluster.
- Sort by hue to see the full range rather than the biggest areas first.
- Use the eyedropper. Click the exact pixel you want and add it to the palette.
Shadows and highlights add another twist. A red jacket in a photo contains bright red, mid red and near-black red, and the clusters may split it three ways or merge the dark part with other shadows. If a key colour looks muddy in the palette, pick it from a well-lit area with the eyedropper rather than relying on the cluster average.
How do you turn extracted colours into a usable palette?
Raw extracted colours are a starting point, not a finished system. A practical web palette needs a few roles:
| Role | What to look for | Typical share of a layout |
|---|---|---|
| Background / neutral | A light or dark, low-saturation colour from the image | Most of the page |
| Primary | The colour that most represents the image or brand | Buttons, links, key headings |
| Accent | A small, vivid colour, often found with the eyedropper | Highlights, badges, illustrations |
| Text | A very dark or very light neutral with strong contrast | All body copy |
Many designers use a rough 60-30-10 split between neutral, primary and accent as a starting point. Once you have your key colours, generate tints and shades so you have lighter and darker versions for hover states, borders and backgrounds. Our guide to building a palette with OKLCH shows how, and the contrast checker and palette generator builds a full 50–950 scale from one colour.
Contrast: Each swatch in the extractor shows its contrast ratio with white and with black text. 4.5:1 or more passes WCAG AA for normal text; 3:1 passes for large text and icons. Colours that fail both are decoration only. See WCAG contrast ratios explained.
Getting colours from a website or a brand
To match an existing website, take a screenshot and drop it in; the eyedropper reads exact pixel values. Bear in mind that screenshots can shift colours slightly if your display uses a wide-gamut colour profile, so confirm critical brand colours against the site’s CSS or the brand guidelines. For a mood board, combine several photos into one image first so the palette reflects the whole set.
Before committing to a palette, check it with the colour-blindness simulator. Colours extracted from nature photos often include reds and greens of similar lightness, which can merge for people with colour vision deficiency; our guide to designing for colour blindness explains the fix.
Exporting the palette
The extractor exports CSS custom properties, SCSS variables, a Tailwind colour object or JSON, or a PNG of the swatches for a mood board. Custom properties are the most flexible for the web:
:root {
--brand-sand: #e8d5b7;
--brand-sea: #2a6f97;
--brand-coral: #f07167;
--brand-ink: #13293d;
}
Give each colour a role-based name, such as --color-primary, once you have decided how it will be used. Names like --blue-2 become confusing when the brand colour changes.
Try it
Drop a photo, logo or screenshot into the colour palette from image tool, choose how many colours you want, pick any extra details with the eyedropper and copy the code. The image never leaves your device.
Last checked: October 2026.
Sources: Björn Ottosson: A perceptual color space for image processing (OKLab), W3C: Understanding SC 1.4.3 Contrast (Minimum).


