Guide

How to Get a HEX or RGB Color Code From an Image

Reading the exact color of a pixel in a photo, screenshot or logo

You have a photo, a screenshot or a logo and you need the color in it as a code you can paste into CSS, a design tool or a paint-matching app. The code is not stored anywhere you can look at; a picture is just a grid of pixels, and each pixel carries three numbers. Picking a color means reading those numbers for one pixel and showing them in a format people use. This guide walks through doing that with the Color ID picker, and covers the things that make a picked color differ from what you thought you saw.

Step by step with Color ID

  1. Open the Image Picker tab. Drag an image onto the drop zone, or press Choose file or Upload. PNG, JPG, WEBP and GIF files all work. On a device with a camera you can press Camera to capture a single frame instead.
  2. Zoom in with the + button on the canvas if the spot you want is small. The label shows the zoom level and Reset returns to 100%.
  3. Click the pixel you care about. The side panel fills in the HEX, RGB and HSL values for that point, plus the closest color name.
  4. Press the copy icon beside the value you need. HEX is the usual choice for CSS; RGB is handy for design apps that ask for three separate numbers.
  5. Your last picks collect in the History row, so you can sample several spots and copy them afterwards.

What the three values are

All three describe the same color. A single orange pixel might read #FF8000, 255, 128, 0 and 30, 100%, 50%. The first two are the same data written differently: hexadecimal pairs for red, green and blue versus plain decimal numbers from 0 to 255. HSL re-expresses the same color as a position on the color wheel plus how vivid and how light it is. The HEX, RGB and HSL guide covers the arithmetic in detail.

Why your pick may not match what you expected

One pixel is not one color

Photos are noisy. Two neighbouring pixels on a wall that looks uniformly beige can differ by several units in each channel because of sensor noise and JPEG compression. If you click once, you get one sample. Click three or four nearby spots and compare. If the values are close, any of them will do; if they swing widely, the surface is textured or the file is heavily compressed, and the representative color is somewhere in the middle.

Edges are blends

Where a logo meets its background, the edge pixels are a mix of both colors because of anti-aliasing. Zoom in and click well inside the shape, not on its outline.

Lighting and white balance are baked in

A picked value is the color in the file, not the color of the physical object. A white shirt photographed under warm indoor bulbs will read yellowish, and the same shirt in shade will read bluish. If you want to match a real paint or fabric, take the photo in even daylight, avoid direct flash, and include something known to be neutral (a sheet of white paper) in the frame so you can judge the cast. Screens also differ: the same numbers look a little different on a calibrated monitor and on a phone with a vivid display mode.

Compression changes colors

JPEG compression works on blocks of pixels and discards some color detail. A PNG screenshot of a flat color will give you the exact value that was drawn, while a JPEG of the same screen can be off by a few steps. When you have the choice, sample from a PNG.

Picking from the dominant colors

When an image loads, Color ID also fills a Dominant Colors row with up to eight swatches. To produce it, the page shrinks a copy of the image to 100 pixels wide, rounds every channel to the nearest multiple of 20, and counts how many pixels land in each bucket. The eight most common buckets become swatches. That makes it quick for finding the overall mood of a picture, but the swatch values are rounded, so they will not match any single pixel exactly. When you need the precise value, click that region in the image itself.

Using the code you copied

You copiedWhere it goes
HEX, e.g. #3A7BD5CSS (color: #3A7BD5;), most web builders, design tools
RGB, e.g. 58, 123, 213CSS as rgb(58, 123, 213), graphics software sliders, game engines
HSL, e.g. 215, 65%, 53%CSS as hsl(215 65% 53%), handy when you want a lighter or darker variant

If the color you got is close to what you need but not right, paste it into the Converter tab, switch between formats, and nudge the lightness in HSL until it fits.

Privacy of the images you load

The image is read by your browser and drawn onto a canvas on your own device. The file is not uploaded for picking. The privacy policy explains the small number of requests the page does make, such as fonts, and the third-party services that run on the site.

Keep reading

Open the color picker