Start a project

Tool 02 of 29 · Colour

Image Palette Extractor

Drop in a photo, logo or screenshot and get its main colours as CSS variables, with every text and background pair checked for contrast.

Image Palette Extractor

Your image

For the CSS variables, like --palette-1

Choose an image to start, or use the sample photo.

Palette

    Text and background pairs that pass

    SamplePairRatioGood for
    CSS variables
    JSON

    01

    What it does

    Pulls the main colours from any photo, logo or screenshot and shows which text and background pairs pass WCAG.

    • 3 to 12 colours, found by k-means clustering in OKLab
    • Share of the image for each colour
    • White and black text contrast on every swatch
    • Every pair that passes WCAG AA or AAA

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    CSS variables, JSON and a palette PNG, with a Copy and a Download button on every result.

    • Colour
    • WCAG
    • OKLab
    • CSS variables

    Why it matters

    Clients often arrive with a logo, a shop front or a favourite photo and nothing else. Picking colours from it by eye with an eyedropper gets you one pixel, which is often a shadow or a highlight rather than the colour people actually see.

    This tool groups every pixel into clusters in OKLab, a colour space built around how people perceive colour, so the results match what you'd point at. Then it does the part that usually gets forgotten: it checks which combinations can be used for text, so the palette is accessible from the start rather than fixed later.

    How to use it

    1. Choose or drop an image, or use the sample photo.
    2. Pick how many colours you want. Six suits most brand palettes.
    3. Check the contrast badges on each swatch and the table of pairs that pass.
    4. Copy or download the CSS variables, JSON or palette image.

    FAQ

    Why don't the colours exactly match my eyedropper?

    Each colour is the average of a cluster of similar pixels, which is closer to what you see than any single pixel. For an exact colour from a logo file, use the hex code from the brand guidelines.

    Is my image uploaded?

    No. It's drawn onto a canvas in your browser and read there. Nothing is sent anywhere.

    Why is the image scaled down?

    The tool samples a smaller copy (up to 160 pixels across) so it works instantly on phones. It makes no visible difference to the palette.

    Which pairs can I use for body text?

    Anything marked AA text or AAA text: a contrast of at least 4.5:1. Pairs marked Large text / UI need 24px text or bigger, or are for borders and icons.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk