Color Palette from Image: Extract HEX, RGB & HSL Codes

Color Palette from Image: Extract HEX, RGB & HSL Codes

Upload a photo or logo and extract 3 to 12 dominant colors as HEX, RGB and HSL. Export CSS variables, Tailwind, JSON or PNG. Nothing leaves your browser.

Updated November 2026

Reviewed by Rafael Duarte

How to extract a color palette from an image

From photo to production-ready palette in seconds

1. Upload your image

Drop a JPG, PNG, WebP, GIF or SVG (up to 20 MB) on the box, browse your files, or use Or extract from a URL for a public image.

2. Pick how many colors

Choose 3, 4, 5, 6, 7, 8, 10 or 12 swatches. The default is 6, and changing the count extracts again right away.

3. Copy or export

Click a swatch to copy its HEX code, or export as CSS Variables, Tailwind, JSON or DESIGN.md, or use Download PNG.

What this color palette extractor does

K-means clustering, not a blurred average

Groups similar pixels with k-means

The image is shrunk to 150 px on its longest side, about 8,000 pixels are sampled, and k-means groups them by distance in RGB. Each color is the average of one group, not a muddy average of the whole photo.

K-means++ initialization

Starting points are spread across the image's colors, and the algorithm runs for up to 25 rounds. The start is random, so Re-extract can give slightly different colors.

HEX, RGB and HSL on every swatch

Each swatch shows its HEX code, with rgb() and hsl() on hover. Click it to copy the HEX. Swatches are sorted from darkest to lightest.

5 export formats

CSS Variables (--color-1 and up), a Tailwind config, JSON with HEX/RGB/HSL, a DESIGN.md color table, and Download PNG for a swatch card with HEX and RGB.

Processed in your browser

Extraction runs on the Canvas API in your browser, so private photos and brand assets never leave your device.

Usage examples

Scenario
Recommended setting
Brand identity from a logo
4–6 colors
UI design system
6–8 colors for more semantic roles
Mood board / illustration reference
8–12 colors for full-spectrum coverage

When you'll reach for this tool

The most common scenarios among people using this generator

Brand identity from a logo

Extract 4–6 colors and document precise HEX values for brand guidelines and Figma libraries.

Web design and development

Export the palette to a Tailwind extend.colors block or CSS variables without picking swatches by hand.

Photography and mood boards

Pull the exact color mood out of a reference photo to guide an edit or a shoot.

Interior design and material matching

Get precise color values from a room photo to match paint or fabric swatches.

Common mistakes

Confusing dominant color with average color

Clustering keeps separate groups of similar pixels apart; an average blends every pixel into one muddy tone that may not appear anywhere in the image.

Expecting a bigger image to give better colors

The image is scaled down to at most 150 px on its longest side before extraction, so high resolution doesn't change the result. The color composition does.

Asking for too many colors from a simple logo

A logo with two or three colors doesn't need 12 swatches. Extra slots end up as near-duplicates or edge-blend tones, so 3 to 6 is usually enough.

Reading the order as dominance

Swatches are sorted by lightness, darkest first, not by how many pixels they cover. The same order sets the DESIGN.md role names, so its "Primary" row is simply the darkest color: rename the roles to fit your design.

Pasting the Tailwind export into Tailwind v4

The export is a tailwind.config.js file with module.exports (the v3 format). In Tailwind v4, copy the HEX values into an @theme block instead.

Why use this tool

K-means returns real color groups from your image instead of one blended average, and k-means++ seeding keeps the starting points spread out so small accent colors still get a chance to show up.

Besides CSS, Tailwind, JSON and PNG, it can export a DESIGN.md color table with role, token, HEX, RGB and HSL columns, handy for documenting a palette in a repository. Need one exact pixel instead of a palette? The eyedropper in the hex color picker grabs it from your screen.

Dominant color vs. average color

Why k-means matters

Dominant colors (k-means)
Average color
Method
groups similar pixels and averages each group
averages every pixel together
Result on a sunset photo
separate tones for sky, sun and shadows
one blurred midtone
Colors returned
3 to 12, your choice
1

Frequently asked questions

Drop your image on the upload box. Extraction runs in your browser with k-means clustering and returns the main color groups as HEX, RGB and HSL values, sorted from darkest to lightest (not by how much of the image each one covers).

Further reading

Related Tools