OfflaneAI

Color palette from image —
HEX, RGB and CSS in one click

Drop a photo, logo or screenshot and get its 3–12 main colours instantly. Click anywhere on the image to pick an exact pixel. Copy the HEX list, CSS variables or download a palette image.

  • 🎨 3–12 dominant colours
  • 🖱️ Click to pick any pixel
  • 📋 Copy HEX · CSS variables
  • 🔒 Nothing is uploaded

Loading the tool… (JavaScript required)

How are the colours chosen?

A k-means clustering of the image's pixels finds the colours that best represent it, sorted by how much of the image they cover — the same method design tools use. Increase the count to get accent colours, decrease it for a tighter brand palette.

Can I get the exact colour of one spot?

Yes — click on the image and that pixel's HEX and RGB are added to the palette. Useful for picking a brand colour from a logo or matching a colour from a photo.

What can I export?

A plain HEX list, CSS custom properties (--color-1: #a1b2c3;) ready for a stylesheet, or a PNG strip of the swatches with their codes for a mood board.

How to extract a palette from an image

  1. Add the image. Drop a JPG, PNG, WebP or HEIC file on the upload area, click it to choose a file, or paste a screenshot with Ctrl+V.
  2. Read the swatches. The palette appears at once, sorted from the colour that covers most of the picture to the one that covers least. Each card shows the HEX code, the RGB values and the share of the image in percent.
  3. Set “Number of colours”. The slider goes from 3 to 12 and starts at 6. The palette is recalculated as you move it.
  4. Copy a single colour. Click a card and its HEX code is copied to the clipboard.
  5. Pick an exact spot. Click anywhere on the picture. A “Picked” line shows that pixel as HEX, RGB and HSL, with a “Copy” button.
  6. Export. Use “Download palette PNG”, “Copy as CSS variables” or “Copy HEX list”.

How the colours are found

The tool shrinks the image to 160 px on its longer side and groups the pixels of that small copy into as many clusters as the slider says. This is k-means clustering: each pixel joins the cluster whose colour is nearest, each cluster’s colour is recalculated as the average of its pixels, and the two steps repeat 12 times.

Three details explain what you see on screen.

  • Swatches are averages. A swatch is the mean of all pixels in its cluster. On a photo it may be a tone that no single pixel has. For a colour that must match exactly, click the picture instead.
  • Transparent pixels are skipped. In a PNG with a transparent background only the visible part is counted.
  • Tiny clusters are dropped. A cluster that covers less than 0.5% of the image is not shown, so you can ask for 12 colours and get 9.

The starting colours are spread evenly from the darkest to the lightest pixel, not chosen at random. The same image and the same count always give the same palette.

There is no AI model and nothing to download for this tool. The clustering is ordinary arithmetic on 25,600 pixels at most, done in the page itself, which is why the palette updates while you drag the slider. The image is decoded and analysed in your browser, so an unreleased brand guide or a client mock-up is not sent anywhere.

Choosing the number of colours

JobNumber of coloursWhy
Brand colours from a flat logo3–5A logo has few real colours; more slots only split the edges
Website theme from a hero photo5–6Background, surface, text and one or two accents
Mood board or illustration reference8–10Keeps shadows and highlights as separate tones
Finding a small accent colour10–12Small areas get their own cluster only at high counts
Gradient or sky3–4Higher counts return several steps of the same hue

If two swatches look nearly the same, the count is too high for this image. If an obvious colour is missing, raise the count or click that spot.

Picking a single pixel

A click on the picture reads one pixel and shows it in three notations: HEX, rgb() and hsl(). HSL is shown only here, not on the palette cards.

Things to know before relying on the value:

  • One picked colour at a time. A new click replaces the previous one. Copy the code before you click again.
  • Not part of the exports. The PNG strip, the CSS block and the HEX list contain the extracted palette only.
  • Large images are reduced first. A picture wider or taller than 1400 px is scaled down to 1400 px when it is loaded. A one-pixel line in the original is then blended with its neighbours.
  • Edges are mixed colours. The rim of a letter or icon is smoothed with the background. Click in the middle of a flat area.
  • Transparent spots return black. A click on an empty part of a PNG gives #000000.

What each export contains

ButtonResultTypical use
Download palette PNGA strip of 200 px squares with the HEX code printed under each on a white band, 260 px highMood boards, briefs, slides
Copy as CSS variablesA :root block with --color-1, --color-2 and so on, numbered by coverageStylesheets, design tokens
Copy HEX listThe codes on one line, separated by commasChats, notes, palette importers

The PNG is named after your file with -palette added. Its width is 200 px times the number of swatches, so 6 colours give a 1200 × 260 px image.

Using the palette in design tools

CSS and front-end frameworks

Paste the copied block into your stylesheet and refer to a colour as var(--color-1). The numbers follow coverage, not purpose, so rename the variables to what they mean in your design, for example --color-bg and --color-accent. For Tailwind, move the HEX values into the colors section of the theme.

Figma, Canva and slides

These tools take a HEX code in the colour field of any fill. Paste the codes one by one, or place the palette PNG on the canvas as a reference and sample from it.

Icons and vector artwork

When you trace a logo with the image to SVG converter, the swatch count here is a good guide for its colour slider. To build a browser icon on a matching tile, enter a HEX code from the palette as the background colour in the favicon generator.

Getting a more useful palette

Remove what you do not want counted

A product on a white table gives a palette that is mostly white and grey. Cut the subject out with the background remover and load the transparent PNG: the empty area is ignored and every slot goes to the product.

Crop to the area that matters

For the colours of one garment, one wall or one part of a painting, cut that region out with the crop tool first. The percentages then describe the region, not the whole frame.

Use a clean source

A JPG saved at low quality carries blocks and colour fringes that shift the averages slightly. A PNG, or the original export from a design tool, gives the codes the designer chose.

What the tool does not do

  • No colour names, Pantone or CMYK. The output is HEX and RGB for screens, plus HSL for a picked pixel. For print, convert the values in your layout software with the printer’s colour profile.
  • No harmony suggestions. It reports the colours that are in the image. It does not propose complementary or analogous colours.
  • No contrast check. Dominant colours of a photo are rarely a readable text and background pair. Test them against the WCAG ratio of 4.5:1 for body text before using them in an interface.
  • No swatch files. There is no ASE or JSON export; use the HEX list.

Troubleshooting

I asked for 12 colours and got fewer

Clusters under 0.5% of the image are hidden. The picture simply has fewer distinct colour areas than that.

The brand colour is slightly off

The swatch is an average that includes smoothed edge pixels. Click the flat part of the logo and use the “Picked” value.

A small bright detail is missing from the palette

It covers too little of the image to form its own cluster. Raise the count to 10–12, crop closer, or click the detail.

The variable numbers changed after I moved the slider

Swatches are always numbered by coverage. A different count regroups the pixels, so --color-3 can become another colour. Settle on the count first, then copy the CSS.

The picked colour is black on a transparent logo

You clicked an empty area. Click the artwork itself.