Skip to content
Utilboxes

Color Palette Extractor

Add a photo, logo or screenshot and choose how many colours you want to get its main colours as HEX, RGB and HSL codes, with each colour's share of the image and a text contrast check. Copy the palette as CSS variables, a Tailwind theme or JSON, or click the image to sample one point. Nothing is uploaded.

Files never leave your device

Updated

How to use the Color Palette Extractor

  1. 1Add an image.
  2. 2Choose how many colours you want in the palette.
  3. 3Copy any colour code, or copy the whole palette as CSS variables, a Tailwind theme or JSON.
  4. 4Click a point on the image to read the colour at that spot.

How it works

The image is scaled down and read pixel by pixel in your browser. Similar pixels are grouped into buckets — 32,768 of them, five bits per colour channel — so a photo with millions of pixels becomes a few thousand weighted colours that can be analysed instantly.

Those colours are clustered with k-means in CIELAB colour space. Distance in CIELAB matches how different two colours look to the eye far more closely than distance in RGB, so the palette favours colours that are visibly distinct rather than several near-identical shades of one background.

The starting points are chosen deterministically — the most common colour first, then whichever colour is furthest from those already chosen — so the same image always gives the same palette. A colour's share is the proportion of the image's opaque pixels closest to it; transparent pixels are ignored.

Each colour also shows whether white or black text reads better on top of it, with the WCAG contrast ratio, which helps when turning a palette into a design.

Tips and common mistakes

  • Raise the number of colours if a small accent colour is missing; it may have been absorbed into a larger neighbour.
  • Click directly on the image to sample one exact spot.
  • Use the contrast figures before choosing a colour as a text background: 4.5:1 is the minimum for body text.
  • Copy the palette as CSS variables, a Tailwind theme or JSON to drop it straight into a project.

Frequently asked questions

Why is a small but striking colour missing from the palette?
The palette is weighted by how much of the image each colour covers, so a tiny accent can be absorbed into a larger neighbouring cluster. Increase the number of colours, or click the spot on the image to sample it directly.
Are the colours exact?
Palette colours are the average of their cluster, so they are representative rather than copied from one pixel. The click-to-sample colour is read from a single pixel of the scaled-down copy of your image.
What does the contrast ratio mean?
It is the WCAG 2 contrast between the colour and white or black text. 4.5:1 is the minimum for normal body text at level AA; 3:1 is enough for large text.
Is my image uploaded?
No. The pixels are read and clustered on your own device.
How many colours should I extract?
Five to eight is typical for a design palette. Use more if the image has several important but small colours.
Does the same image always give the same palette?
Yes. The starting points are chosen in a fixed way, so the result does not change from one run to the next.
Which colour formats can I copy?
HEX, RGB and HSL for each colour, and the whole palette as CSS variables, a Tailwind theme or JSON.

Guides