On-device AI — professional-grade, fully private.

Images

How to Create a Color Palette From an Image (and Use It in CSS)

Turn any photo or logo into a usable color palette: how many colors to take, how to check contrast for readable text, and how to export to CSS or JSON.

Updated November 1, 20269 min read

To make a color palette from an image, add the picture to the color palette generator, choose how many colors you want, and copy the hex codes or download them as CSS or JSON. The tool reads every pixel and returns the colors that represent the picture best. The skill is not in the clicking. It is in choosing a sensible number of colors, checking that text will be readable on them, and getting the result into your stylesheet without retyping it.

What a palette from an image gives you

A palette is a short list of colors, each with a hex code such as #2f5d62, that you can reuse in a design. Pulling one from a photo works because a good photograph is already balanced: the sky, the skin tones, the product and the shadows were all lit by the same light, so the colors sit well together. A brand photo, a packaging shot, a painting or a room you like are all fair starting points.

Each swatch shows its hex code and how much of the image it covers, as a percentage. That second number is useful: a color that covers 40% of a photo is a natural background, while one that covers 3% is a natural accent for buttons and links.

If you only need one color from one spot, the color picker is quicker, and the guide to picking a color from an image covers it. This guide is about getting a whole set.

Create a palette, step by step

1

Add the image

Open the palette generator. Drag the image onto the page, paste it from the clipboard with Ctrl+V (or ⌘V on a Mac), or click Browse. It accepts PNG, JPG, WebP, AVIF, GIF, BMP, SVG and ICO.

2

Set the number of colors

Use Number of colors. It starts at 6. Free goes up to 8, and the lowest setting is 3. Start with 5 or 6 and change it only if the result misses a color you can see in the picture.

3

Pick an extraction algorithm

Under Extraction algorithm, K-means is the default and separates a photo best. Frequency anchors on the largest areas, which suits a logo. Median cut gives rare colors more room, so a small bright accent is more likely to appear.

4

Choose a color mood

Color mood steers which colors are picked: Neutral, Colorful, Bright, Muted, Deep or Dark. The hex codes are always real colors from the image. The mood only changes which ones are chosen.

5

Refine the result

Press Extract palette after changing a setting. Use Shuffle to see a different set from the same image, and lock any swatch you like so it survives the next extraction. Pick from image replaces a swatch with the exact pixel you click.

6

Copy or download

Use Copy all hex values to paste the codes anywhere, or download CSS, JSON or a plain hex list. The Pro formats are listed further down.

Extract 3 to 8 colors from an image and export CSS, JSON or a hex list. Free: one image at a time, up to 25 MB, up to 8 colors. Pro: up to 32 colors and batches of 100. It all runs on your device, not our servers.

Create a color palette

How many colors should you take?

More colors does not mean a better palette. Past a point, an ordinary photo starts returning near-duplicates: three slightly different greens that no designer would keep as separate choices. Most interfaces end up using a handful of colors plus neutrals, so a small number is usually the right answer.

UseColors to takeWhy
A logo or flat illustration3 to 5There are only a few real colors, so extra swatches repeat each other
A website or app theme5 to 6One main color, one accent, a background and two neutrals
A presentation or poster4 to 6Enough for text, background and two highlights without clutter
A detailed photograph6 to 8Sky, subject, shadows and highlights each get a swatch
A design system with tint ramps6 to 8, then use the rampsEach swatch can expand into lighter and darker steps

If the tool says the image only contains a few distinguishable colors, believe it. A flat two-color logo has two colors, and asking for eight cannot make up six more.

Extraction algorithm and mood: which to choose

The three algorithms read the same pixels and report exact colors. They differ in what they favor, so the right one depends on the picture.

SettingBest forWhat to expect
K-meansPhotographsSwatches that look clearly different from each other
FrequencyLogos, packaging, flat artThe colors that cover the biggest areas, with no blended in-between shades
Median cutImages with a small bright detailRare colors get more room, so an accent is more likely to appear

Moods work like filters on the choice. Colorful favors saturated colors, Bright favors light saturated ones, Muted favors soft mid-tones, Deep favors dark rich ones and Dark favors shadows. The same sunset photo can give you a punchy poster palette on Colorful and a calm website palette on Muted, and both are honest colors from the picture.

If your image is a logo or icon with a transparent background, leave Transparent pixels on Ignore. Transparent pixels are stored as black, so including them adds a black swatch to a logo that has none.

Check contrast before you use the colors

A palette can look lovely and still be unreadable once you put words on it. The contrast section lists the WCAG contrast ratio for pairs of colors in the palette, and shows which pairs reach AA. Here is what those labels mean in practice.

LabelRatio neededApplies to
AA4.5 to 1Normal body text
AA large3 to 1Large text (about 24 px, or 19 px bold) and button outlines
AAA7 to 1The stricter level, worth aiming for on long reading text
FailBelow 3 to 1Do not use this pair for text

The section Text on each swatch tells you whether dark text or light text works better on every color. That answers the most common practical question: what color should the writing on this button be? Mid-tone colors are the usual trouble, because neither black nor white may reach 4.5 to 1 on them. Darken the swatch, or use its tint and shade ramp to find a step that works.

There is also a colour-vision check. Set Simulate colour vision to Protanopia, Deuteranopia or Tritanopia and the swatches are repainted as a viewer with that condition sees them. The page names any pair that becomes hard to tell apart. Red and green are the classic collision, and the fix is to differ in lightness as well as hue, or to add a label or an icon. Both checks are free on every plan.

Harmony and tint ramps

Once you have a main color, the Harmony section suggests partners by rule: Complementary, Analogous, Triadic, Split, Tetradic and Mono. Analogous colors sit next to each other on the wheel and feel calm. Complementary colors sit opposite and feel energetic, so use them sparingly, for one call-to-action rather than the whole page.

The Tints and shades ramp under each swatch gives you lighter and darker versions of the same color. That is how you get a pale background, a hover state and a dark text color without leaving the palette. If a color is close to grey, the tool says so and shows the ramp instead of inventing a complement. To understand the codes themselves, see hex, RGB and HSL explained, and use Hex to RGB when a program wants a different notation.

Exporting to CSS, JSON and design tools

Exporting is the point of the tool, since nobody extracts a palette just to look at it. The free formats cover most web work. The Pro formats carry the palette into other software.

FormatPlanWhere it goes
CSSFreeCustom properties you paste into a stylesheet
JSONFreeDesign tokens, scripts and apps that read data files
Hex listFreeA plain list for documents, chat and notes
SCSSProSass variables
TailwindProA theme block for a Tailwind stylesheet
ASEProAdobe Illustrator, InDesign and Photoshop swatches
GPLProGIMP, Inkscape and Krita palettes
SVG and PNGProA swatch card to share with a client or team

The CSS export gives each color as a custom property, so you can write var(--name) throughout your styles and change a color in one place. Keep the variable names about roles rather than colors, such as primary, accent and surface, because a color named blue becomes a lie the day the brand turns green.

What Free covers and what Pro adds

FreePro
Colors per image3 to 8Up to 32
Images at once1Up to 100
File size per imageUp to 25 MBNo fixed cap, limited by your device
Export formatsCSS, JSON, hex listAdds SCSS, Tailwind, ASE, GPL, SVG, PNG
Algorithms, moods, harmony, rampsAll includedAll included
Contrast and colour-vision checksAll includedAll included

The cap on Free is on scale, not on whether the tool works. You get the full set of algorithms, moods, harmonies, ramps and accessibility checks without paying. Pro is for people who extract many images in one go, need more than 8 colors, or move palettes into design software.

When the palette looks wrong

  • Everything looks grey or muddy. The image has large dull areas such as pavement or fog. Switch the mood to Colorful, or use the eyedropper to pick the accent you wanted.
  • A color you can see is missing. It covers too small an area. Raise the number of colors, try Median cut, or replace a swatch with Pick from image.
  • A black swatch appears on a logo. Set Transparent pixels to Ignore.
  • Two swatches look almost the same. Lower the count by one or two.
  • The file is rejected as too large. Free handles up to 25 MB per image. Compress it first, since a palette does not need full resolution.
  • The hex code does not match your design file. Screens, profiles and compression shift colors slightly. The palette reports the average of the real pixels, so for one specific spot use the eyedropper.

Frequently asked questions

How do I create a color palette from an image for free?

Add the image to the palette generator, choose 3 to 8 colors, and copy the hex codes or download CSS, JSON or a hex list. Free handles one image at a time, up to 25 MB.

How many colors should I extract from a photo?

Five or six suits most websites and presentations. Use three to five for a logo and up to eight for a detailed photograph. More swatches usually just repeat similar shades.

Can I get the CSS code for my palette?

Yes. The CSS export is free and writes each color as a custom property you can paste into a stylesheet. JSON and a plain hex list are free too. SCSS and Tailwind are Pro.

How do I know if text will be readable on my palette colors?

Open the contrast section. It shows the contrast ratio for pairs of colors and whether they reach AA, which needs 4.5 to 1 for normal text. The Text on each swatch list says whether dark or light text works better.

Is the hex code exactly the color in my image?

Each swatch is the average of the real pixels it represents, so a flat red logo returns that exact red. For a single exact spot, use Pick from image or the color picker.

Is my image uploaded when I extract colors?

No. The image is read on your device, not on our servers, so private photos and unreleased brand work stay with you.

Keep reading

More in Images →