Image Color Palette Generator: Extract Colors (HEX, RGB)

Upload an image and get its 5 to 10 dominant colours with percentages in HEX, RGB and HSL, exported as CSS, Tailwind or JSON. Nothing leaves your browser.

How to extract colours from an image

To extract the dominant colours of an image, it is shrunk, its pixels are read and then grouped by median cut: the most populated group of pixels is sorted along its widest channel (red, green or blue), split at the median pixel, and each group is averaged into one colour. The tool returns 5 to 10 colours with their percentage.

Steps

  • The image is redrawn on a canvas of at most 160 px: even a 24-megapixel photo stays fast.
  • Pixels whose alpha is below 128 are ignored, which handles transparent PNGs.
  • Median cut produces between 5 and 10 groups; the share of each colour is its pixel count divided by the total.
  • HSL conversion: hue, saturation and lightness are computed from R, G and B scaled to 0-1, with l = (max + min) ÷ 2.

Example

An image made of 50 red pixels, 30 blue pixels and 20 transparent ones gives two colours: #ff0000 at 62.5% and #0000ff at 37.5%, the transparent pixels not being counted.

Export formats

CSS variables (--palette-1: #ff0000;), Tailwind configuration and a JSON array with HEX, RGB, HSL and percentage.

Limits

The resulting colour is an average: it may match no pixel exactly. A high-contrast photo with few groups loses detail; raise the number of colours for more nuance. Processing is local, the image is never uploaded.

Sources and dates: the median cut algorithm was described by Paul Heckbert in "Color Image Quantization for Frame Buffer Display", ACM SIGGRAPH Computer Graphics, vol. 16, no. 3, July 1982, pp. 297-307. The tool applies a simple variant (the most populated group is split at the median pixel of its widest channel). The RGB to HSL formulas are the classic conversion formulas, with values rounded to integers (checked on 14/10/2026)

Frequently Asked Questions

How do I extract colours from an image?

Upload the image to the tool: it is shrunk then analysed with median cut, which returns 5 to 10 dominant colours with their percentage. Copy them as HEX, RGB or HSL.

Is my image uploaded to a server?

No. Your browser reads and analyses the image through a canvas, with no network request at all. It is gone from memory as soon as you close the page.

How do I get the HEX code of a colour in a photo?

Run the analysis, then copy the HEX value of the shade you want, for example #3a7bd5. For the exact colour of one pixel, use an eyedropper instead; here each colour is the average of a group of pixels.

Is this tool really free?

Yes, all tools on Kristools are 100% free and accessible without registration.

Is my data protected?

Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.