When you pick a color from an image you get back a handful of codes: #3AA0C4, rgb(58, 160, 196), hsl(196, 54%, 50%) and cmyk(70%, 18%, 0%, 23%). They all describe exactly the same color. They are just different ways of writing it down, each designed for a different job. This guide explains how each format works and when to use it.
Quick overview
| Format | What it describes | Range | Use it for |
|---|---|---|---|
| RGB | Amounts of red, green and blue light | 0–255 per channel | Screens, code, image editing |
| HEX | RGB written in hexadecimal | 00–FF per channel | CSS, HTML, design handoff |
| HSL | Hue, saturation, lightness | 0–360°, 0–100%, 0–100% | Adjusting colors, building scales |
| HSV/HSB | Hue, saturation, value (brightness) | 0–360°, 0–100%, 0–100% | Color pickers in design apps |
| CMYK | Cyan, magenta, yellow and black ink | 0–100% per ink | Printed material |
RGB: red, green and blue light
Every pixel on your screen is made of three tiny lights: one red, one green and one blue. By varying how brightly each one glows, a screen can produce millions of colors. RGB describes a color as the intensity of each of those three lights, usually on a scale from 0 (off) to 255 (full brightness).
rgb(255, 0, 0)is pure red: the red light at full power and the others off.rgb(255, 255, 0)is yellow, because red and green light combine to make yellow.rgb(255, 255, 255)is white: all three at full power.rgb(0, 0, 0)is black: all lights off.rgb(128, 128, 128)is mid grey. Equal values always produce a neutral grey.
Because the light is added together, RGB is called an additive color model. With 256 possible values per channel there are 256 × 256 × 256 = 16,777,216 possible colors, often called “24-bit” or “true color”.
In CSS you can add a fourth value for transparency (alpha), from 0 (invisible) to 1 (solid): rgb(58 160 196 / 0.5) is our example color at 50% opacity.
HEX: RGB in shorthand
A HEX code is simply an RGB color written in hexadecimal, a base-16 number system that uses the digits 0–9 and the letters A–F. Two hex digits can represent any number from 0 (00) to 255 (FF), so six digits are enough for all three channels:
# 3A A0 C4
│ │ └── blue = C4 = 12×16 + 4 = 196
│ └─────── green = A0 = 10×16 + 0 = 160
└──────────── red = 3A = 3×16 + 10 = 58HEX became the standard way to write colors on the web because it is compact, easy to copy and paste, and supported everywhere: HTML, CSS, SVG, Figma, Sketch, Photoshop, Canva and almost every other design tool.
Shorthand and transparency
- If each pair has two identical digits, you can shorten the code to three digits:
#FF6600→#F60. - An optional fourth pair adds transparency:
#3AA0C480is about 50% opaque (80= 128 of 255). - HEX codes are not case-sensitive.
#3aa0c4and#3AA0C4are identical.
You can estimate a HEX color without converting it. Look at the first digit of each pair: the higher the digit, the more of that channel. In #E8F4FD all three are high (E, F, F), so it is a very light color, slightly blue because the last pair is highest.
HSL: hue, saturation and lightness
RGB and HEX are how computers think about color. HSL is closer to how people think about it. Instead of mixing lights, you describe:
- Hue: the position on the color wheel, from 0° to 360°. 0° is red, 120° is green and 240° is blue.
- Saturation: how vivid the color is, from 0% (grey) to 100% (fully saturated).
- Lightness: from 0% (black) through 50% (the pure color) to 100% (white).
The big advantage of HSL is that it makes adjustments predictable. Want a lighter version of your button color for a hover state? Increase the lightness. Want a muted version for a disabled state? Lower the saturation. With HEX you would have to change all three channels by trial and error.
#B8DDEA#7DC0D8#3BA0C4#2B7691#1B495AOne limitation of HSL is that equal lightness values don’t always look equally light. Yellow at 50% lightness looks much brighter than blue at 50%. Newer formats like oklch() fix this, as explained in our CSS colors guide.
HSV / HSB: hue, saturation and value
HSV (also called HSB, for brightness) looks similar to HSL but measures the third value differently. In HSV, 100% value means “as bright as possible”, which is the pure color, not white. To get white you reduce the saturation to 0% at 100% value.
HSV is the model behind the square-and-slider color pickers in Photoshop, Illustrator, Affinity and Procreate. The square shows saturation horizontally and value vertically. If you need to type a color into one of those apps, the HSV/HSB values from our picker will match exactly.
CMYK: cyan, magenta, yellow and key (black)
Printers can’t emit light. They put ink on paper, and each ink absorbs some of the light that hits it. That makes CMYK a subtractive model: the more ink you add, the darker the result.
- Cyan absorbs red light.
- Magenta absorbs green light.
- Yellow absorbs blue light.
- Key (black) is added because mixing the three colored inks gives a muddy dark brown rather than a true black, and wastes ink.
CMYK values are percentages of ink coverage. cmyk(0%, 100%, 100%, 0%) is a bright red made from full magenta and full yellow.
Converting RGB to CMYK with a formula gives a useful approximation, but real printed colors depend on the printer, the inks and the paper. Many bright screen colors, especially vivid blues, greens and oranges, simply cannot be printed with CMYK inks. Read why colors change when you print before sending artwork to a printer.
Which format should I use?
- Building a website or app: HEX for sharing and documenting colors. HSL or OKLCH when you want to generate variations in code. RGB when you need transparency in older code.
- Handing colors to a developer: HEX. It is unambiguous and everyone recognises it.
- Working in Photoshop, Procreate or similar: HEX or HSB.
- Designing anything printed (business cards, flyers, packaging): CMYK, ideally taken from your design software’s print profile, or a Pantone spot color for exact brand matching.
- Choosing or tweaking colors by feel: HSL, because each number maps to something you can see.
Converting between formats
HEX and RGB convert perfectly in both directions because they are the same values written differently. Converting to HSL or HSV involves rounding, so going back and forth can occasionally shift a channel by 1. That difference is invisible. Converting to CMYK is an approximation, as explained above.
You don’t need to do the maths yourself. Paste any value into our free color converter to get every format at once, or use the image color picker to get all five formats straight from a photo or screenshot.