Color Palette from Image
Extract dominant colors from any image. Get hex codes and CSS variables instantly.
What Is a Color Palette Extractor?
A color palette extractor analyzes the pixels of an image and identifies its most prominent colors. The result is a small set of representative hex codes โ the dominant color palette of that image.
How It Works
The tool uses the k-means clustering algorithm directly in your browser:
- The image is downsampled to a working resolution for speed.
- Pixels are sampled and grouped into k clusters by color similarity.
- Each cluster centroid becomes one palette color.
- Colors are sorted by dominance โ the most frequent color appears first.
No libraries are used. The algorithm runs entirely in JavaScript via the Canvas API.
Common Use Cases
- UI design โ match interface colors to a hero image or product photo
- Brand identity โ extract a palette from a logo or mood board
- Web development โ generate CSS custom properties from an image
- Art & illustration โ analyze color harmony in reference images
- Social media โ create consistent visual themes for feeds
How to Use
- Drop an image onto the upload zone or click to select a file.
- Choose how many colors to extract (2โ12).
- Click Extract palette.
- Click any color row to copy its hex code.
- Click Copy CSS variables to get all colors as
:root { --palette-1: โฆ }.
Frequently Asked Questions
What image formats are supported?
Any format your browser can decode: PNG, JPEG, WEBP, GIF, AVIF, and most others.
Why do results vary slightly between runs?
K-means uses a random initialization step. The final palette is usually stable, but for images with many similar colors, minor variation between runs is normal.
How many colors should I choose?
6 is a good default for most images. Use fewer (3โ4) for simple graphics or logos, more (8โ12) for rich photographs with complex color distributions.
Can I use the extracted hex codes directly in CSS?
Yes. Use the Copy CSS variables button to get a ready-to-paste :root {} block with --palette-1 through --palette-N variables.