Colour Palette Extractor
Colour Palette Extractor
…or drag & drop a JPG, PNG, GIF, or WebP here. Your image never leaves your browser.
How to Use the Colour Palette Extractor
Add an image
Click "Choose an image" or drag a photo, screenshot, logo, or illustration onto the drop zone. JPG, PNG, GIF, and WebP all work. The image is read and processed entirely on your own device — nothing is uploaded.
Choose how many colours
Pick between 2 and 12 swatches. The tool scans the image's pixels, groups similar colours together, and surfaces the most dominant ones — skipping near-duplicates so you get a varied palette rather than six shades of the same blue. If the image has fewer clearly different colours than you asked for, the remaining slots are filled with its next most common shades, which can sit close to ones already shown.
Copy any colour
Each swatch shows its value and roughly what share of the image it covers. Switch between HEX, RGB, and HSL with the toggle, then click any swatch to copy that value straight to your clipboard.
Export to your stack
Grab the whole palette as CSS custom properties, SCSS variables, a Tailwind colour object, or JSON — ready to paste into your stylesheet or design tokens. One click copies the lot.
How Colour Extraction Works
From Millions of Pixels to a Handful of Swatches
A single photograph can contain hundreds of thousands of distinct colours — every pixel is its own red, green, and blue value, and a modern image has millions of pixels. The job of a palette extractor is to boil all of that down to a small, useful set of representative colours: the ones a designer would point at and say "that's the palette." Doing it well is a genuine computer-science problem called colour quantization, and there are several classic approaches — the popularity algorithm, median cut, k-means clustering. This tool uses the first and simplest, the popularity algorithm, which Paul Heckbert's 1980 MIT thesis on colour quantization credits to Tom Boyle and Andy Lippman (1978): it groups the image's pixels into colour "buckets" by keeping only the top four bits of each red, green and blue value (16 levels per channel, 4,096 buckets), counts how many pixels fall into each bucket, and then ranks the buckets by population. The most populated buckets are, by definition, the colours that appear most across the image — the dominant palette. To keep the result useful it also averages the true pixel values inside each bucket (so you get the real colour, not the rounded one) and applies a distinctness filter that skips any candidate too close to a colour already chosen, which is what stops a palette from coming back as six nearly identical shades of sky. The method has a known blind spot, which Heckbert describes: it favours the crowded regions of colour space and can neglect a small, strongly saturated accent. The distinctness filter softens that without curing it, so if a small accent colour matters to you, ask for one or two more swatches than you need.
The percentage on each swatch is the share of the image's opaque pixels closest to that colour: every pixel group counts toward the nearest swatch, so the percentages add up to 100 and the swatches are listed largest first. It tells you which colour is the background, which the accent and which a detail. Until 30 September 2026 the figure counted only the swatch's own narrow colour group, so a background spread across many near-identical shades — a gradient sky, say — could show as a few percent; on a test image that was 70% sky, the old method gave the sky 5%. For speed, the tool works from a copy scaled so its longer side is 160 pixels. Fine detail a few pixels wide can disappear in that copy, but large areas of colour, which are what a palette is about, keep their proportions.
"A good palette extractor does not just find colours — it finds the right colours: dominant, distinct, and in the proportions that actually shape how an image feels."
Where Palettes Get Used
Extracted palettes turn up everywhere in design and front-end work. A brand designer pulls colours from a mood-board photo to anchor a visual identity. A developer matches a UI to a hero image so buttons and accents feel like they belong. Data-visualisation authors sample a palette to keep a chart on-brand. Even non-designers use it to answer the everyday question "what's the exact colour of that thing in this picture?" — for which a clickable HEX swatch is far faster than fiddling with an eyedropper in heavyweight image software. Because this tool exports directly to CSS variables, SCSS, Tailwind, and JSON, the palette goes straight from image to code with no retyping of hex codes. And because everything runs locally in your browser, you can extract colours from confidential mock-ups, unreleased product shots, or client work without uploading a single byte to a third-party server — a small but real consideration when the image itself is the sensitive asset.
Reducing millions of colours to five is called quantization
A 24-bit image can hold 16.7 million distinct colours — 256 each of red, green, blue.
Reducing those millions to a few swatches is called colour quantization; this tool uses its oldest method, the popularity algorithm.
HEX and RGB describe the same colour — #ff0000 is just rgb(255,0,0).
HSL (hue, saturation, lightness) is often easier for humans to reason about than RGB.
The eye is most sensitive to green: WCAG's relative-luminance formula for sRGB weights green 0.7152, red 0.2126 and blue just 0.0722.
This tool samples a copy 160 pixels on its longer side — large colour areas keep their share, and it is instant.
A distinctness filter stops the palette from returning near-identical shades.
The percentages add up to 100: every pixel counts toward the swatch nearest to it.
Pixels less than about half opaque (alpha under 125 of 255) are ignored, so a logo on a clear background extracts cleanly.
Everything runs in your browser — your image is never uploaded anywhere.
Frequently Asked Questions
- Upload or drag in your image and the tool instantly shows its dominant colours as swatches. Each swatch displays its HEX value, and clicking it copies that value to your clipboard. You can switch the display to RGB or HSL with the toggle, and export the whole set as CSS, SCSS, Tailwind, or JSON.
- It uses the popularity algorithm: the tool groups the image's pixels into colour buckets (the top four bits of each channel), counts how many pixels fall into each, and ranks them by population — so the colours that cover the most of the image come first. It is not k-means or median cut, and like any popularity method it can pass over a small saturated accent; ask for an extra swatch or two if one matters. It then averages the real pixel values in each bucket for an accurate swatch and skips any colour too similar to one already chosen, so you get a varied palette rather than several near-identical shades.
- No. The image is read and analysed entirely in your browser using an HTML canvas — it is never uploaded, stored, or sent anywhere. This means you can safely pull colours from confidential designs, unreleased product shots, or client work. You can even use the tool offline once the page has loaded.
- It is the share of the sampled image that the colour represents. A swatch at 60% is the dominant colour — often the background — while one at 5% is a small accent or detail. The percentages help you understand the role each colour plays, not just its value, which is useful when deciding which should be your primary, secondary, or accent colour.
- Yes. After extraction, choose CSS custom properties, SCSS variables, a Tailwind colour object, or JSON, and copy the result with one click. The CSS option gives you ready-to-use
--color-1through--color-nvariables; Tailwind gives acolorsobject with keyspalette-1onward, in order of share (they werebrand-100–600, which wrongly suggested Tailwind's light-to-dark shade scale). No retyping hex codes by hand. - Anything your browser can display: JPG, PNG, GIF, WebP, and usually AVIF and SVG. Pixels less than about half opaque in PNGs, GIFs and WebPs are ignored, so a logo on a clear background gives you just its real colours rather than picking up the checkerboard or white fill behind it.
- For a brand or UI palette, five or six is usually the sweet spot — enough for a primary, a secondary, an accent, and a couple of neutrals. Increase the count if an image is very colourful and you want to capture more nuance, or drop to two or three if you just want the headline colours. You can change the number any time and the palette updates.
- Each swatch is the average of a group of similar pixels, so it represents a region of colour rather than one exact pixel. This gives a more honest "dominant" colour than picking a single pixel, which might be an outlier. If you need the exact value of one specific spot, an eyedropper tool is better; for a representative palette, averaging is the right approach.
- Yes. It works on any raster image — photos, screenshots, UI mock-ups, illustrations, and logos. Flat graphics with a few solid colours extract especially cleanly because their pixels cluster tightly, so the palette closely matches the design's actual swatches.
- Completely free, with no account, sign-up, or usage limit. The extraction runs entirely in your browser and nothing about your image is sent anywhere. Extract palettes from as many images as you like.
Method & sources
How it computes
Popularity algorithm (Heckbert 1980): the image is scaled to 160 px on its longer side; pixels at least ~half opaque (alpha ≥ 125) are bucketed by the top 4 bits of R, G and B; the most populated buckets (each its pixel average) become swatches, skipping any within 42 RGB units of one chosen. Every bucket counts toward its nearest swatch; shares sum to 100. 2–12 swatches. Computed in your browser, tested.
What this tool implements
- Method named: the popularity algorithm — quantise each primary to a few bits, count the clumps, keep the K most popular — credited to Tom Boyle and Andy Lippman (1978) in Heckbert's 1980 MIT thesis, which used 5 bits per primary (this tool uses 4). Not k-means, not median cut.
- Heckbert records the method's weakness: it "frequently neglects sparse, but remote, regions of the color cube". The page now says a small saturated accent can lose its slot, and the tests pin that case (a 5% accent absent from three swatches, present from four).
- Corrected 2026-10-26: the page said near-duplicates are always filtered out; when an image has fewer distinct colours than requested, the remaining slots take the next most common shades, close or not, and the page now says so. The swatch count is clamped to 2–12 (the input box let 0, negatives and 500 through). "Transparent pixels are ignored" now gives the actual rule (alpha under 125 of 255). The free-use answer's "collects no data" is narrowed to the image.
- Green-sensitivity fact grounded in WCAG 2.2 relative luminance for sRGB, L = 0.2126 R + 0.7152 G + 0.0722 B.
Sources
- Heckbert PS. Color Image Quantization for Frame Buffer Display. BSc thesis, Massachusetts Institute of Technology, 1980 — "The Popularity Algorithm". https://www.cs.cmu.edu/~ph/ciq_thesis
- Heckbert P. Color image quantization for frame buffer display. ACM SIGGRAPH Computer Graphics 1982;16(3):297-307. doi:10.1145/965145.801294
- W3C. Web Content Accessibility Guidelines (WCAG) 2.2 — relative luminance. https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
What can make this go out of date
- None at runtime: the image is decoded and sampled in the browser's own canvas and never uploaded.