Palette Extractor

Color Palette Generator

Drop any photo, illustration or logo and instantly extract its dominant color palette. Get HEX, RGB, HSL codes, CSS variables, and downloadable swatches.

Last updated: August 2026

4–12

Colors

HEX + RGB + HSL

All Formats

CSS

Ready

Private

No Uploads

Drop any image here

PNG, JPG, WebP, GIF, SVG or AVIF. Works well on photos, illustrations and logos.

Your file never leaves this device.

Choose image

How to generate a color palette

1

Drop or select your image

PNG, JPG, WebP, GIF, SVG, BMP, AVIF or HEIC. Nothing is uploaded.

2

Choose how many colors

4, 6, 8 or 12. Simple images may return fewer.

3

Copy or download

Click a swatch to copy its HEX, or export CSS, HEX list, JSON or a PNG sheet.

How color extraction works

The tool uses a color quantization algorithm called Median Cut, run iteratively rather than through recursive function calls, to avoid any risk of a stack overflow on very detailed images. Rather than simply averaging all the pixel colors in the image (which would produce a single muddy middle color), Median Cut intelligently divides the color space to find colors that together best represent the full range of hues in the image.

  1. 1

    Downsample

    The image is scaled down to a maximum of 200x200 pixels before processing. Color distribution is accurately represented at this size, and the smaller pixel count keeps extraction fast even on large source images.

  2. 2

    Read pixel colors

    All pixel colors are read from the canvas as RGB values. Pixels more than roughly half transparent are excluded, not just fully transparent ones, since they carry little useful color information. This leaves a flat array of all the colors present in the image.

  3. 3

    Iterative Median Cut quantization

    Starting from a single bucket holding every pixel, the algorithm repeatedly finds whichever current bucket has the greatest color range on any channel (red, green or blue), sorts that bucket by that channel, and splits it in half at the median. This repeats, always targeting the bucket with the most range, until the desired number of groups is reached.

  4. 4

    Average and deduplicate

    Each final bucket is averaged to produce one representative color. If two buckets land on the exact same HEX value, the duplicate is dropped, which is why a simple or flat-colored image can return fewer swatches than the count you selected.

  5. 5

    Sort by luminance

    The final colors are sorted from lightest to darkest using perceived luminance weighting (which accounts for the human eye's different sensitivity to red, green and blue).

What people use color palette extraction for

Building UI color systems

Extract colors from a hero image or product photo and use them as the foundation of a website palette. The CSS variables output pastes directly into a stylesheet.

Brand color identification

Upload a company logo or brand asset to identify its exact color codes. Useful when you have the visual asset but not the original design files.

Photo-matched design

Design landing pages, social posts or presentations that match the color mood of a specific photograph by building the UI palette from the photo itself.

Illustration and art reference

Extract the color palette from a reference illustration, film still or painting to use as inspiration or to match a specific visual style.

Content consistency

Ensure blog posts, social media graphics and marketing materials use colors that match a featured image by extracting its palette before designing.

Design system documentation

Use the PNG swatch download to document color palettes in design specs, Notion pages, Confluence docs or Figma files as image assets.

Export formats explained

CSS variables

:root {
  --color-1: #f5c842;
  --color-2: #e87d3e;
  --color-3: #2b4c8c;
}

Paste directly into your stylesheet. Reference colors anywhere with var(--color-1). Change the prefix in the tool to match your naming convention.

HEX list

#f5c842
#e87d3e
#2b4c8c

A plain list of HEX codes, one per line. Paste into Figma, Sketch, Canva, or any tool that accepts HEX codes. Also useful for storing in a plain text file.

JSON

{
  "color1": "#f5c842",
  "color2": "#e87d3e",
  "color3": "#2b4c8c"
}

For developers storing palettes in config files, design token systems, or passing colors through an API. Compatible with Style Dictionary and similar design token tools.

PNG swatch sheet

Downloadable image with color blocks and HEX/RGB labels only, HSL is not included in the export.

For documentation, design specs, client presentations, Notion pages and anywhere you need a visual reference of the palette as an image file.

Common palette extraction mistakes

Expecting exactly the number of colors selected

Duplicate buckets get merged and splitting stops early once a bucket has no range left. A flat-color logo asked for 12 swatches might legitimately return far fewer, that's the algorithm working correctly, not a bug.

Assuming the PNG export includes HSL

The on-screen palette shows HSL alongside HEX and RGB, but the downloadable PNG swatch sheet only prints HEX and RGB labels. Copy the HSL value directly from the swatch if you need it.

Reading too much into 'fully transparent' pixel exclusion

Pixels more than roughly half transparent are excluded, not just pixels at zero opacity. On images with soft transparent gradients or overlays, this threshold affects which colors get counted.

Expecting the most visually striking color to dominate

The algorithm extracts statistically dominant colors, not the most eye-catching ones. A large muted sky or background can outrank a small, vivid subject in the resulting palette.

Why use ImgTweak?

Runs entirely in your browser
No uploads, ever
CSS variables, HEX list, JSON and PNG export
Accepts PNG, JPG, WebP, GIF, SVG, BMP, AVIF and HEIC
Free forever, no account needed
Works on mobile as well as desktop

Frequently asked questions

How does the color extraction work?

The tool uses an iterative Median Cut algorithm to extract dominant colors from your image. The image is downsampled to 200x200 pixels for speed, then all pixel colors are read via the browser Canvas API. Starting from one bucket containing every pixel, the algorithm repeatedly finds whichever current bucket has the greatest color range on any channel, sorts that bucket by that channel, and splits it at the median. This continues until the target number of buckets is reached. Each bucket is then averaged to produce one representative color, and the results are sorted from lightest to darkest by perceived luminance.

Can I get fewer colors than I selected?

Yes. If two buckets end up averaging to the exact same HEX color, the duplicate is removed. Splitting also stops early if the remaining bucket has no color range left to divide. Simple logos, flat-color graphics or images with very limited color variety can return fewer swatches than the count you selected, this is expected rather than a bug.

What is the difference between this and the Image Color Picker?

The Image Color Picker lets you click a specific pixel to read its exact color. It is for when you need a precise color from a specific point in the image. The Color Palette Generator automatically analyzes the entire image and extracts the most dominant colors across all regions. It is for when you want to understand what colors an image is built from, or when you want to build a UI palette inspired by a photo, illustration or brand asset.

How many colors should I extract?

4 colors works well for simple images, logos and graphics with flat color. 6 colors is a good default for most photos and illustrations. 8 colors captures more variation and works well for complex or colorful images. 12 colors is for images with a wide range of distinct hues such as festival photography, detailed illustrations or design mockups. For web UI use, 4 to 6 dominant colors is usually enough to build a complete palette.

What is the CSS variables output for?

The CSS output is a :root block containing the extracted colors as CSS custom properties (CSS variables). You can paste this directly into your stylesheet. Each variable is named with the prefix you set (defaulting to --color-1, --color-2, etc.) and you can then reference them anywhere in your CSS with var(--color-1). This is the fastest way to turn a palette extracted from an image into a set of usable design tokens for a web project.

What's included in the downloadable PNG swatch sheet?

Each swatch block is labeled with its HEX code and RGB value. The HSL value shown in the on-screen palette is not included in the PNG export, only HEX and RGB are printed onto the downloaded image.

Are transparent pixels included in the extraction?

Pixels that are more than roughly half transparent are excluded from the analysis, not only pixels that are completely transparent. This keeps mostly-transparent edges and overlays from skewing the extracted palette toward whatever color happens to be underneath them.

Is my image uploaded to a server?

No. The entire extraction runs in your browser using the Canvas API. Your image is drawn onto a hidden canvas element and the pixel data is read locally. Nothing is sent to any server. You can disconnect from the internet after the page loads and the tool still works.

Why does the palette look different from the original image?

The algorithm finds the most statistically dominant colors across the entire image, not the colors that look most visually prominent. On photos with a large sky or background, muted sky blues may dominate even if a smaller subject is more visually striking. This is a property of algorithmic color quantization. If you need a specific color from a specific part of the image, use the Image Color Picker to click directly on the area you want.

Ready to extract a color palette?

No sign-up. No upload to server. Drop your image above and copy the colors in seconds.