Skip to content

Hex color converter

Convert a hex color code to RGB, HSL, CMYK and decimal, or build a color from RGB sliders.

#

3 or 6 digits, 0-9 and a-f. Shorthand like 3bf expands automatically.

Color values

Hex color

#3b82f6

Type a hex code, drag the sliders, or share the link below.

RGB
-
HSL
-
CMYK
-
Decimal
-

How it works

A hex color code is a six-digit hexadecimal value, such as #3b82f6, that packs three two-digit pairs for the red, green and blue components on a 0 to 255 scale. The calculator converts a hex code to RGB, HSL, CMYK and decimal at once, and works the other way from the RGB sliders too.

  1. Type a hex code

    With or without the leading #. 3-digit shorthand like 3bf works too.

  2. Or drag the sliders

    Red, green and blue update the hex code and every other format live.

  3. Read the conversions

    RGB, HSL, CMYK and decimal all update together.

Converting hex to RGB

Split the six-digit hex code into three pairs and read each one as a base-16 (hexadecimal) number. For #3b82f6: 3b is 59, 82 is 130 and f6 is 246, so the color is RGB(59, 130, 246).

decimal = (R × 65536) + (G × 256) + B

For RGB(59, 130, 246): (59 × 65536) + (130 × 256) + 246 = 3,866,624 + 33,280 + 246 = 3,900,150. This single number is the hex code read as one base-16 integer instead of three separate pairs.

HSL, hue, saturation, lightness

HSL describes a color as a position on a 360-degree hue wheel (0 degrees is red, 120 is green, 240 is blue), plus saturation, how intense the color is, and lightness, how close it is to black or white. RGB(59, 130, 246) is HSL(217°, 91%, 60%): a strong, fairly light blue.

CMYK for print

CMYK (cyan, magenta, yellow, key/black) describes how much ink a printer subtracts from white paper, unlike RGB and HSL which describe light added on a screen. The calculator estimates CMYK from RGB using the standard subtractive conversion; real print output also depends on the printer and paper.

RGB and CMYK are not exact opposites

The RGB to CMYK formula used here is a common approximation (it assumes pure additive and subtractive primaries), not the color profile a real printer uses. For color-critical print work, use the printer or press's own ICC profile instead of a generic formula.

Frequently asked questions

How do I convert a hex color code to RGB?

Split the six-digit hex code into three pairs and convert each from base-16 to decimal. For #3b82f6: 3b is 59 red, 82 is 130 green, f6 is 246 blue, giving RGB(59, 130, 246). The calculator does this instantly and also shows the HSL, CMYK and decimal equivalents.

What is HSL and how does it differ from RGB?

HSL stands for hue, saturation, lightness. Hue is the color angle on a 360-degree wheel (0 degrees is red, 120 is green, 240 is blue), saturation is color intensity from 0 to 100%, and lightness is brightness from 0% black to 100% white. RGB mixes light channels directly, while HSL is closer to how people describe color by eye.

Can I use a 3-digit hex color code?

Yes. A 3-digit hex code like #3bf is shorthand for #33bbff, each digit doubled. The calculator accepts 3-digit codes and expands them automatically. Both formats are valid CSS color values.

What does the decimal value of a hex color represent?

The decimal value is the six-digit hex code read as a single base-16 integer. For #3b82f6: (59 × 65536) + (130 × 256) + 246 = 3,900,150. This single number uniquely identifies the color and shows up in some programming contexts in place of the hex string.

How does the calculator estimate CMYK from RGB?

It finds black (K) as one minus the largest of the red, green and blue fractions, then derives cyan, magenta and yellow from how far each channel falls short of that. For RGB(59, 130, 246) this gives roughly 76% cyan, 47% magenta, 0% yellow and 4% black. It is a standard approximation for screen colors, not a substitute for a printer's own color profile.