Colour Palette from Image
The dominant colours of an image, with their share and CSS or JSON export.
About Colour Palette from Image
Extract the 3 to 12 dominant colours of an image as HEX, RGB and HSL, with each colour's share of the picture and CSS or JSON export.
How to use
- Choose an image or drop it on the page: PNG, JPEG, WebP, GIF, BMP, AVIF or SVG, up to 25 MB.
- Set how many colours you want, from 3 to 12. The palette updates as you move the slider.
- Each row shows a swatch, the share of the image that colour stands for, and its HEX, RGB and HSL values. Click a value to copy it.
- Copy or download the whole palette as CSS custom properties or as JSON.
What it does
- Scales the image down so its longest side is at most 200 px, which keeps the work quick and changes the result very little.
- Groups the pixels with a median-cut style quantiser: all colours start in one box, and the box whose colours vary most is split in two, at the point that separates its halves best, until there are as many boxes as colours requested.
- Reports each box as the average of its pixels, most common first, with its share of the image. For flat artwork the result is the exact colour; for a photo it is the average of a range of similar shades, so it may not match any single pixel.
- Ignores pixels that are more than half transparent.
- Returns fewer colours than asked for when the image has fewer distinct ones.
It does not name colours, build colour harmonies or check contrast. Values are the sRGB numbers your browser decodes, without further colour management.
Example
Image: a flat graphic that is 60% crimson, 30% blue, 10% white
#DC143C 60% rgb(220, 20, 60) hsl(348, 83%, 47%)
#0000FF 30% rgb(0, 0, 255) hsl(240, 100%, 50%)
#FFFFFF 10% rgb(255, 255, 255) hsl(0, 0%, 100%)
:root {
--color-1: #DC143C;
--color-2: #0000FF;
--color-3: #FFFFFF;
}
Privacy
The image is read and analysed by your browser. It is never uploaded, and nothing is stored.
Frequently asked questions
- How do I get a colour palette from an image?
- Open the image here and choose how many colours you want. The tool groups similar pixels and lists the dominant colours with their HEX, RGB and HSL codes, ready to copy one at a time or export as CSS variables or JSON.
- How does a palette generator find the dominant colours?
- By colour quantisation. This tool uses a median-cut style method: it puts every pixel colour in one box, repeatedly splits the box with the widest spread of colours, and reports the average colour of each final box together with how many pixels fell into it.
- Why is an extracted colour not exactly a colour in my photo?
- Each palette entry is the average of a group of similar shades, so in a photograph it sits between them. In flat artwork such as a logo, where each area is a single colour, the extracted values are exact.
- How do I use an image palette in CSS?
- Copy the CSS export, which declares the colours as custom properties on :root (--color-1, --color-2 and so on), paste it into your stylesheet, and refer to a colour with var(--color-1).