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
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
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).
Upload the photo and each swatch shows its HEX code; click it to copy. Hover a swatch to see rgb() and hsl() too, or open the JSON export to get all three formats for every color at once.
No. All processing happens locally through the Canvas API. With Or extract from a URL, your browser loads the image directly from that address; images whose server doesn't allow cross-origin access (CORS) can't be read, so download them and upload the file instead.
JPG, JPEG, PNG, WebP, GIF, and SVG, up to a 20 MB file size limit. The image is scaled to 150 px on its longest side before extraction, so resolution does not affect the result.
4 to 6 colors is a common range: one primary, one or two secondary colors, a couple of neutrals and an accent.
A clustering algorithm that splits the pixels into K groups of similar colors and returns the average of each group. Here the similarity is the straight-line distance between colors in RGB, not a perceptual color space like Lab or OKLCH.
Yes. The Tailwind tab gives a tailwind.config.js snippet with theme.extend.colors entries named palette-1, palette-2 and so on. That's the Tailwind v3 config format; in Tailwind v4, copy the HEX values into an @theme block as --color-* variables.
Further reading
Related Tools
- Color Scheme Generator: Complementary, Triadic & Analogous Design Pick a base color and get 5 harmonious colors: analogous, monochromatic, complementary, triadic or tetradic. Preview them on a site, export CSS or JSON.
- Color Contrast Checker: WCAG AA/AAA & Color Blindness Design Check if text and background pass WCAG 2.2 AA and AAA, get the nearest passing text color and preview 4 types of color blindness. Free, in your browser.
- HEX to RGB Converter with HSL & CMYK Values Design Paste a HEX code and copy its RGB, HSL and CMYK values instantly, with 4 harmony colors, a contrast check against white and CSS palette export.
- CSS Box Shadow Generator: Tailwind, Neumorphism & Glass Design Create CSS box shadows with a live preview and ready-made presets, or switch to neumorphism and glassmorphism. Copy as CSS, a Tailwind class or a variable.
- Flexbox Generator: CSS, Tailwind & React Code Design Build flex layouts with a live preview and 11 presets, set grow, shrink and order per item, then copy the code as CSS, Tailwind classes or React styles.