Extract colors from an image

The extractor analyzes the image pixels and groups similar shades to reveal the colors that appear the most, ready to copy or export.

Extracted palette

    What an image color extractor is for

    A good photo already contains a finished palette: the light, the materials and the setting combine in a way that would be hard to invent from scratch. The extractor turns that combination into HEX codes you can use in any project. The most common uses are:

    If you need the code of one specific spot rather than the dominant colors, use the image color picker, which reads the exact color of the pixel you click.

    How k-means finds the dominant colors

    An ordinary photo holds tens of thousands of distinct shades, many of them only one or two RGB units apart. The extractor has to group those shades into a handful of representative colors, and it does so with k-means, a classic clustering algorithm. In plain terms:

    1. Sampling: the tool reads up to 20,000 pixels from the image. Transparent pixels are skipped, so the empty background of a PNG never shows up as a fake color.
    2. Starting points: the algorithm picks as many centers as the number of colors you asked for. The k-means++ initialization spreads those centers across clearly different shades, and because it is deterministic, the same image always produces the same palette.
    3. Assignment: every pixel joins the closest center, meaning the color it resembles most.
    4. Update: each center moves to the average color of its group. Steps 3 and 4 repeat until the groups stop changing.

    Each final group becomes a palette color, and the percentage shown is the share of sampled pixels that belong to it. The proportional bar makes this visual: a color covering 40% of the image takes up 40% of the bar. Since every color is an average, it may not match any single pixel exactly, but it stands in well for the family of shades it summarizes.

    How many colors to choose

    The slider goes from 3 to 12 colors. The right number depends on what you need:

    CountWhat you getBest for
    3 to 5Only the main color massesBrand identity, website palette, banner background
    6 to 8Main colors plus a few accentsMoodboards, illustration, patterns
    9 to 12Transition shades, shadows and small detailsImage analysis, digital painting, retouching

    A reliable approach is to start at 5 and work up. If a color you can clearly see in the photo, such as a small red detail, is missing, raise the count: with few groups, small areas get absorbed by the larger neighboring color. If you see several nearly identical shades, lower it.

    Tips for a cleaner result

    All processing happens in your browser, and the image is never sent to a server. Once the palette is ready, click a color to copy its HEX, or export the palette as CSS variables, JSON or a PNG image. The PNG is handy for dropping into a moodboard or sending to a client. For more ways to identify colors in photos, see the guide on how to find a color from an image.

    Turning an extracted palette into a UI palette

    Colors taken straight from a photo rarely work as-is in an interface. A landscape may yield five mid-tones of similar lightness, and none of them works as a background or text color. To turn an extraction into a usable UI palette:

    1. Pick the accent. It is usually the most saturated color with a small percentage, the one that catches your eye in the photo. It becomes the color for buttons and links.
    2. Derive the neutrals. Take the dominant color and create very light versions for backgrounds and very dark ones for text. A warm near-white such as off-white often works better than pure white next to a warm photo.
    3. Fill the gaps with the generator. Enter the accent as the base color in the palette generator, lock it and try harmony rules for the secondary colors.
    4. Check contrast. WCAG asks for at least 4.5:1 for normal text against its background. Test every pairing in the contrast checker and darken or lighten shades until they pass.

    The guide on building a website color palette explains how to split roles between primary color, neutrals and status colors.

    Frequently asked questions

    How are the dominant colors calculated?

    We use the k-means algorithm: pixels are grouped by color similarity and each group becomes a palette color, together with the share of pixels it represents.

    How many colors can I extract?

    From 3 to 12. A few colors summarize the image’s identity; more colors reveal details and transition shades.

    Why does the palette change slightly with large photos?

    To keep the tool fast, large images are sampled. The result is stable and represents the color distribution well.

    Can I use the palette in a commercial project?

    Yes. Colors are not copyrighted; just check the usage rights of the original image if you plan to publish it.