ZeroTool Workbench

Image Color Palette Extractor

Extract dominant colors from any image with k-means in your browser. HEX, RGB, HSL, OKLCH, plus CSS variables and Tailwind config. No upload, no signup.

100% Client-Side Your data never leaves your browser Free · No Sign-Up

Drop image here, click to select, or paste (Ctrl+V)

JPG · PNG · WebP · GIF · SVG · BMP

100% client-side — image never leaves your browser

What this does

Drop in any picture — a UI mockup, a brand asset, a product photograph, a piece of stock art — and walk away with a palette that is ready to paste into your stylesheet, design tokens, or Tailwind theme. The tool clusters the visible pixels with k-means and reports each cluster as a swatch with its weight in the source image, plus four color-space readouts: HEX for design tools, RGB and HSL for legacy CSS, and OKLCH for modern color pipelines.

How to use

  1. Drop an image onto the upload card, click the card to pick a file, or paste with Ctrl + V after copying an image to your clipboard.
  2. Tweak the controls: pick how many colors to extract (3 to 16), sort the result by frequency, hue, or lightness, and toggle filters that drop transparent pixels or near-white pixels.
  3. Click any swatch to copy its HEX value. Click a row inside the swatch to copy that specific format — RGB, HSL, or OKLCH.
  4. Use Copy CSS variables for a :root { --color-1: …; } block, Copy JSON for an array of {hex, rgb, weight}, or Copy Tailwind for a theme.extend.colors.palette snippet.

About the algorithm

K-means is the simplest clustering method that still produces designer-friendly palettes. The picture is downsampled so the longest edge is 200 pixels — a 4K photograph collapses to roughly 40 000 sample pixels, which is enough for stable centroids while keeping runtime under 100 ms on a modern laptop. Each pixel is assigned to the centroid with the smallest squared-RGB distance, centroids are recomputed as the mean of their cluster, and the loop runs until centroids stop moving (or 24 iterations, whichever happens first).

Two practical refinements are layered on top: tiny clusters that drift to within ΔRGB < 6 of another are merged so the output never shows duplicate-looking swatches, and the optional pre-filters drop transparent pixels and near-white pixels (luminance > 0.95) so the algorithm focuses on the colors that carry visual weight rather than padding around the subject.

Output formats

  • HEX — the universal interop format. Click the colored top of any swatch to copy.
  • RGB — modern space-separated syntax (rgb(160 90 44)), compatible with every evergreen browser.
  • HSL — handy when you want to nudge hue, saturation, or lightness without leaving the swatch.
  • OKLCH — perceptually uniform, ideal for design tokens and color pipelines that need to mix or rotate hues without surprises.
  • Weight % — the share of source pixels each centroid claimed; use the dominant entry as a brand accent and the smaller ones as supporting tones.

Privacy

The tool runs entirely client-side. The image is decoded into an HTMLImageElement, drawn onto a hidden canvas at the sampling size, and clustered in JavaScript. Nothing about the picture is sent to any server. If you would like to verify, open the network tab and watch a clean log every time you load a new image.

Related tools

FAQ

How does the tool extract colors?

K-means clustering on the downsampled pixel RGB values. The image is rescaled to a maximum of 200×200 pixels, every visible pixel is grouped into k centroids by Euclidean RGB distance, and each centroid's mean color is reported with its share of the image.

Are my images uploaded anywhere?

No. The image is decoded by your browser via FileReader and Canvas, and clustering runs entirely in JavaScript on your device. Open DevTools' network panel — you will see zero upload requests, only the page assets that loaded with the tool itself.

Which image formats can I drop in?

Any format your browser can decode through an `<img>` element and Canvas: typically JPEG, PNG, WebP, GIF, SVG, BMP, plus AVIF on Chromium and HEIC on Safari. Camera RAW files are not browser-decodable; convert them to JPEG or PNG locally first.

Why does the palette change between runs?

K-means seeds its centroids randomly. With a small `k` and a busy image two runs may converge to slightly different clusters. Click `Re-extract` for a fresh seed, or raise `k` so more centroids cover the color space deterministically.