Color Palette from Image

Extract the main colors of any photo as HEX codes, ready for CSS.

Color Palette from Image tool

Tip: you can also paste a picture with Ctrl+V.

About the Color Palette from Image tool

Designers often start a website, poster or presentation from a photo they love. This tool builds a color palette from image files by finding the dominant colors, from 4 to 12 of them, and showing each as a swatch with its HEX and RGB codes and the share of the picture it covers. The palette can be copied as CSS variables for direct use.

The colors are found with k-means clustering, the method used by most palette generators: similar pixels are grouped together and each group's average becomes one color of the palette. The result is ordered from the most to the least common color, and transparent pixels are ignored, so logos on transparent backgrounds work well. The same picture always gives the same palette.

Copy the palette as CSS custom properties, SCSS variables, a plain HEX list or JSON, or download it as a PNG image to share with a client or add to a mood board. The picture is analysed in your browser, so it is never uploaded.

To read the color of one exact point, use the image color picker. To build matching schemes from a single color, try the color palette generator, and to check text contrast on your new colors, use the contrast checker.

How to use the Color Palette from Image tool

  1. Open a pictureChoose a photo, illustration or logo, or paste it with Ctrl+V.
  2. Choose the number of colorsPick from 4 to 12. Fewer colors give broad themes, more colors capture details.
  3. Review the paletteSwatches are listed from the most to the least common, with HEX, RGB and share.
  4. Copy or downloadCopy the palette as CSS, SCSS, HEX or JSON, or download it as a PNG image.

Color Palette from Image features

  • 4 to 12 dominant colors
  • K-means clustering with repeatable results
  • HEX and RGB codes with each color's share
  • Ordered from most to least common
  • Ignores transparent pixels
  • Export as CSS, SCSS, HEX list or JSON
  • Download the palette as a PNG
  • Nothing is uploaded

Common uses

  • Building a website color scheme from a hero photo
  • Matching slides and graphics to a brand image
  • Creating mood boards for interior and fashion design
  • Finding colors for illustrations based on a reference photo
  • Documenting the colors of an existing logo

Extracting a colour palette from a photo: how it works and how to use it

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Great colour palettes often come from real images: a sunset, a market stall, a painting or a product photo. Extracting the main colours of an image gives you a palette that already works together, because the colours coexisted in one scene. This guide explains how palette extraction works, how many colours to take, and how to turn the result into a usable design palette.

How palette extraction works

A photo contains thousands of distinct colours. Extraction groups similar colours together and finds the most representative colour of each group. A common technique, k-means clustering, starts with a set number of colour groups and repeatedly adjusts them until each group's centre represents its members well. Other methods, such as median cut, repeatedly split the range of colours into halves. Either way, the output is a short list of colours plus how much of the image each one covers.

How many colours to extract

NumberResultBest for
4 to 5broad, dominant colourswebsite themes, brand starting points
6 to 8dominant colours plus accentspresentations, illustrations
10 to 12detailed breakdownanalysing artwork, fashion, interiors

Fewer colours give a simpler, stronger palette; more colours show subtle accents that might make great highlight colours.

Reading the shares

The percentage next to each colour shows how much of the image it represents. Dominant colours with large shares often work as backgrounds or main surfaces. Small-share colours, especially saturated ones, make excellent accents for buttons, links and highlights. A good design usually follows a rough 60-30-10 split: one main colour, one secondary and one accent.

Turning an extracted palette into a design palette

Extracted colours are a starting point. To make them practical:

  1. Choose roles: background, surface, text, primary action and accent.
  2. Adjust for contrast: text colours must contrast strongly with backgrounds; test with Color Contrast Checker.
  3. Create shades: generate lighter and darker versions of key colours with Color Shades Generator for hover states and borders.
  4. Check colour blindness: make sure important distinctions survive with Color Blindness Simulator.

Choosing the right source image

Not every photo yields a useful palette. Images with a clear mood, such as a misty forest, a desert at sunset or a pastel bakery, give coherent palettes. Very busy images with many unrelated colours produce scattered results. Crop the photo to the area with the colours you like using Image Cropper before extracting, for example just the sky of a landscape.

A worked example: a palette for a café website

A café owner photographs a latte on a wooden table next to a green plant. Extracting six colours might give a creamy off-white, a warm milk-coffee brown, a dark espresso brown, a mid wood tone, a muted sage green and a small amount of near-black. Use the off-white as the page background, the dark espresso for text, the milk-coffee brown for section backgrounds and the sage green as the accent for buttons. Test white text on the green; if contrast is too low, darken the green slightly. The website now feels like the café itself, because its colours came from the café.

Exporting for use

Copy the colours as HEX codes for design tools, or as CSS custom properties for websites. Keeping the palette as variables, such as a primary and an accent variable, means you can change the whole site's look later by editing a few lines.

Palettes from brand assets

Extracting colours from your logo and product photos helps create consistent marketing images and slides. For exact brand colours, though, always use the official values from brand guidelines; extraction approximates colours, especially from compressed JPG images.

Quick tips

  • Crop to the area whose colours you want.
  • Try different colour counts and compare.
  • Adjust extracted colours for contrast before using them for text.
  • Save palettes with the source image for reference.

Palettes for presentations and documents

Extracted palettes are useful beyond websites. For a presentation about a place or a product, extracting colours from its main photo and using them for slide titles, chart series and backgrounds makes the whole deck feel connected to the subject. Office programs let you save these as a custom theme, so every new slide and chart picks them up automatically. Keep text dark on light backgrounds or light on dark ones, and use the more saturated colours sparingly for highlights, so the slides stay easy to read in a bright room or on a projector.

Seasonal and campaign palettes

Shops and brands often refresh their colours for seasons and campaigns while keeping their logo the same. Extracting a palette from a campaign photograph, such as autumn leaves or a summer beach, gives a ready-made set of accent colours for banners and social posts that changes with the season but still sits comfortably next to the core brand colours.

Privacy

Palette extraction runs in your browser. The image is never uploaded, so personal photos and unreleased designs stay private.

Frequently asked questions

How do I extract colors from an image?

Open the image and the main colors appear automatically as a palette. Choose how many colors you want, then copy the HEX codes or the whole palette as CSS variables. Each swatch also shows how much of the picture it covers.

How are the dominant colors chosen?

The tool uses k-means clustering: it groups similar pixels together and repeatedly refines the groups until each one has a stable average color. The averages become the palette, ordered by how many pixels belong to each group.

Why does the palette show fewer colors than I asked for?

If the picture contains fewer distinct colors than the number you chose, for example a flat logo with four colors, the tool shows only the colors that really exist rather than inventing near-duplicates.

Why are the colors slightly different from the picture?

Each palette color is the average of a group of similar pixels, so it represents an area rather than one exact pixel. For the exact color of a single point, use the image color picker.

Can I use the palette in my CSS?

Yes. Choose CSS custom properties in the export list and press Copy. You get a :root block with variables such as --color-1, ready to paste into a stylesheet. SCSS variables, a HEX list and JSON are available too.

Are the results the same every time?

Yes. The clustering starts from the same pseudo-random seed, so the same picture with the same number of colors always gives the same palette, which makes it easy to share and reproduce.

Is my image uploaded?

No. The colors are calculated by code running in this page on your own device, and the image is never sent to a server. It is safe for unpublished designs and private photos.