Image Color Palette Extractor - Get HEX, RGB & HSL

Pull the dominant colors out of any image and get them as HEX, RGB and HSL, with a WCAG-safe text color for each swatch. Runs entirely in your browser.

What the Color Palette Extractor Does

This tool answers a narrow question precisely: if you had to describe this image with a handful of colors, which ones would they be? It decodes your image in the browser, scales it down so the longest edge is about 200 pixels, and reads the raw pixel data off a canvas. Downscaling is not a shortcut that costs accuracy — averaging neighbouring pixels during the scale removes JPEG ringing and sensor noise that would otherwise show up as dozens of nearly identical near-blacks, and it keeps the whole analysis under about forty thousand pixels so it finishes instantly even on a phone. Pixels with an alpha value under 128 are discarded before anything else happens. That single step is what stops a logo on a transparent background from reporting black as its main color, which is the most common wrong answer other extractors give. The remaining opaque pixels are grouped with median cut. Median cut treats the pixels as a cloud in three-dimensional RGB space, wraps a box around them, repeatedly picks the box with the widest color spread weighted by how many pixels it holds, and slices it in two at a point where the color values actually change. Repeating that until there are as many boxes as you asked for gives clusters that follow the real structure of the image, and each cluster reports the average of the pixels inside it rather than an arbitrary bucket center. This is why the results are actual colors from your image instead of the washed-out greys that fixed-grid bucketing produces. The ordering is then adjusted. Ranking purely by pixel count is a trap: a photograph is often forty percent sky or white studio backdrop, and a raw count puts that first and buries the colors you actually wanted. Near-neutral, near-black and near-white clusters are therefore given less weight when the list is sorted, though they are never dropped and the percentage shown next to each swatch is always the true, unmodified pixel share. Finally, every swatch gets a text color computed from its WCAG 2.1 relative luminance, choosing black or white by whichever has the higher contrast ratio against that specific color. That test uses luminance, not lightness, so it gets mid-tones right where a simple brightness threshold flips to the wrong answer.

Why Extract a Palette From an Image

Design work usually starts from something visual — a photo, a screenshot, a moodboard, a logo someone emailed you — and ends with values you have to type into code. This closes that gap without a round trip through a design app.

Build a site or app theme from a hero photo, product shot, or brand asset in seconds, with values you can paste straight into CSS or Tailwind
Recover exact HEX codes from a logo or old screenshot when nobody can find the original brand file
Get an accessible text color for every swatch up front, so you are not guessing whether white text will survive on that background
Hand a client or teammate a palette PNG they can read without installing anything or opening a design tool

How to Extract Colors From an Image

Four steps, no account, and nothing leaves your device — the image is decoded and analysed locally in your browser.

1

Drop in a JPG, PNG, WebP, GIF or SVG — extraction starts automatically as soon as it loads

2

Choose how many colors you want: 4 for a tight brand set, 10 to capture more of a busy photograph

3

Click any HEX, RGB or HSL value on a swatch to copy it, or use Copy all HEX to grab the whole set at once

4

Export a CSS variables snippet, a Tailwind config block, or render the palette as a PNG and download it

Frequently Asked Questions

No. It uses median cut, which clusters the pixels in RGB space and repeatedly splits the widest, most populated cluster until it has the number of colors you asked for. Each swatch is the average of a real cluster of pixels, so it is a color that genuinely appears in the image. Ranking is by pixel share, but near-grey, near-black and near-white clusters are weighted down so that a large flat background does not push the actual accent colors off the list. The percentage shown on each swatch is still the true pixel share, unweighted.
Usually because the largest area of an image is not the color you notice. A product photo can be sixty percent white cyclorama while your eye locks onto the red object in the middle. This tool damps neutrals for exactly that reason, but the effect is deliberate and moderate rather than absolute, so on an image that really is mostly one neutral, that neutral still wins. If you want more of the accents, raise the color count to 8 or 10 and the smaller clusters get their own swatches instead of being merged into the big ones.
Yes, and this is one of the main reasons to use it. Any pixel with an alpha value below 128 is thrown away before the analysis starts. Without that step, drawing a transparent PNG onto a canvas gives fully transparent pixels an RGB value of zero, and tools that skip the check report black as the dominant color of almost every logo. If an image is entirely transparent there is nothing to sample, and you get a clear message rather than a palette of black.
It is black or white, whichever has the higher WCAG 2.1 contrast ratio against that swatch. The calculation converts the color to relative luminance using the sRGB gamma curve and applies the standard (L1 + 0.05) / (L2 + 0.05) formula. That matters because the crossover point sits at a luminance of about 0.179, which does not correspond to fifty percent lightness. A color like #767676 looks dark enough for white text if you judge by HSL lightness, but black text actually scores higher. Each swatch renders its own labels in the color it recommends, so what you see is the real result.
Four suits logos, flat illustrations and anything you want reduced to a tight brand set. Six is a good default for most photographs and gives you a primary, a secondary, and enough supporting tones to build a UI. Eight to ten is for complex images — busy scenes, gradients, artwork — where the extra slots pick out accents that would otherwise be averaged into their neighbours. Changing the count re-runs the whole extraction rather than just trimming the list, so a six-color result is not simply the first six of a ten-color result.
The CSS file is a :root block with one custom property per color, named --color-1 through --color-n in the same order shown on screen, plus a --color-dominant alias for the first one. Each line has the pixel share in a trailing comment so you can see how prominent that color was. The Tailwind file is a config snippet with the colors nested under theme.extend.colors.palette, giving you classes like bg-palette-1 and text-palette-3 once you merge it into your own config. Both are plain text files you can open and edit.
No. The file is decoded in your browser, drawn to an in-memory canvas, and read back as pixel data there. No image data, no palette, and no filename is transmitted to any server, which means confidential mockups, unreleased product shots and client artwork stay on your machine. It also means the tool keeps working if you go offline after the page has loaded, and there is no upload size cap beyond what your device's memory allows.
Anything your browser can decode, which in practice means JPG, PNG, WebP, GIF and SVG. Animated GIFs are sampled from their first frame. SVG files work as long as they declare intrinsic dimensions, since the browser needs a size to rasterise them at. Very large photographs are fine — the image is scaled down before sampling, so a 6000-pixel-wide RAW export costs no more analysis time than a thumbnail.

More Image Tools

Explore other powerful tools for your image editing needs