---
title: "Color Palette from Image – Extract HEX | ImgSprint"
description: "Get a color palette from image files: extract the dominant colours of any photo as HEX and RGB swatches, then copy them or export CSS. No upload needed."
url: https://imgsprint.com/tools/color-palette-extractor/
---

1.  [Home](https://imgsprint.com/)
2.  [Tools](https://imgsprint.com/tools/)
3.  Color Palette Extractor

# Extract a Color Palette from Any Image New!

Get a color palette from image files: extract the dominant colours of any photo as HEX and RGB swatches, then copy them or export CSS. No upload needed.

-   No upload
-   Free, no sign-up
-   No watermark

## Colour palette extractor

Select image

or drop an image here

JPG, PNG, WebP, AVIF, GIF

## How to use the Color Palette Extractor

1.  1

    ### Add an image

    Drop a photo, logo, illustration, or screenshot.

2.  2

    ### Pick how many colours

    Choose 3 to 12 swatches. The palette is recalculated instantly.

3.  3

    ### Copy what you need

    Click any swatch to copy its HEX code, or copy RGB values from the list.

4.  4

    ### Export

    Download the palette as CSS variables, JSON, or a PNG swatch card.

## What you can do

### Smart clustering

A k-means algorithm groups similar pixels, so you get the colours that actually dominate — not random samples.

### One-click copy

Copy HEX or RGB for any swatch, or the whole palette at once.

### Developer exports

Ready-to-paste CSS custom properties, Tailwind-friendly JSON, and a shareable PNG card.

### Runs locally

The image is analysed in your browser — nothing is uploaded.

## Turning a photo into a colour palette

Every great palette starts somewhere — a sunset, a product shot, a competitor’s landing page, a painting you love. This tool reads every pixel of your image and finds the handful of colours that best describe it. Under the hood it uses **k-means clustering**: it places a few “centres” in colour space, assigns each pixel to the nearest one, moves each centre to the average of its pixels, and repeats until nothing moves. The result is a set of representative colours plus the share of the image each one covers.

## Getting a useful palette

-   **Crop first.** If you only care about a product or a logo, [crop](https://imgsprint.com/tools/crop-image/) away the background so it does not dominate the palette.
-   **Start with five or six colours.** That is enough for a primary, secondary, accent, and two neutrals. Go higher for illustrations with many hues.
-   **Check contrast.** Palette colours are averages, so they are often mid-tones. For text, pair the darkest and lightest swatches and confirm a contrast ratio of at least 4.5:1.
-   **Need an exact pixel?** Use the [image colour picker](https://imgsprint.com/tools/color-picker/) to sample a precise spot.

## Using the exports

**CSS variables** drop straight into a stylesheet (`--color-1: #0D9488;`), and the **JSON** export works with design tokens, Tailwind config files, or Figma plugins. The **PNG card** is handy for mood boards and client presentations: it shows each swatch with its HEX code underneath. Like every ImgSprint tool, the analysis happens on your device — your image is never uploaded.

## Frequently asked questions

How are the dominant colours chosen?

The image is shrunk to about 200 pixels on its longest side and every pixel is grouped with k-means clustering (seeded with k-means++). Each swatch is the average colour of one group, and the percentage shows how much of the image that group covers.

Why does the palette change when I change the number of colours?

With more clusters, large areas split into finer shades; with fewer, similar shades merge. Try 5–6 colours for a brand palette and 8–12 for illustration work.

Are transparent pixels counted?

No. Pixels that are mostly transparent (alpha below 50%) are ignored, so a logo on a transparent PNG gives you just the logo colours.

What is the difference between this and the Image Color Picker?

The Color Picker samples the exact colour under your cursor. The Palette Extractor analyses the whole image and summarises it into a handful of representative colours.

Can I use the colours commercially?

Colours themselves cannot be owned, so yes. Just make sure you have the rights to use the source image itself if you publish it.

More in Utilities

-   [Remove Image Metadata](https://imgsprint.com/tools/remove-exif/)
-   [View EXIF Data](https://imgsprint.com/tools/view-exif/)
-   [Image Color Picker](https://imgsprint.com/tools/color-picker/)

[All tools](https://imgsprint.com/tools/)

Private by design

Your image is processed by your own browser. It is never uploaded, stored, or seen by us.

## Related tools

[### Image Color Picker Sample exact colors from an image and copy HEX, RGB, or HSL.](https://imgsprint.com/tools/color-picker/)[New! ### QR Code Generator Make QR codes for links, WiFi, or UPI — with colours and your logo.](https://imgsprint.com/tools/qr-code-generator/)[New! ### Screenshot Beautifier Put screenshots on a gradient with padding, shadow, and a browser frame.](https://imgsprint.com/tools/screenshot-beautifier/)[### Compress Image Shrink JPG, PNG, WebP, and AVIF files with a live quality slider.](https://imgsprint.com/tools/compress-image/)[### Resize Image Set exact dimensions or scale by percentage, with aspect-ratio lock.](https://imgsprint.com/tools/resize-image/)[### Crop Image Crop to freeform or preset ratios with a live pixel preview.](https://imgsprint.com/tools/crop-image/)
