Skip to content

HEX to RGB Color Converter

Decode any HEX color code (3, 4, 6 or 8 digits, including alpha) into RGB, RGBA and HSL, and check whether black or white text will be readable on it.

#06B6D4 = rgb(6, 182, 212)

RGB
rgb(6, 182, 212)
HSL
hsl(189, 94%, 43%)
6-digit HEX
#06B6D4
White text
2.43:1 · fails
Black text
8.65:1 · passes AA

How to Read a HEX Color Code

A six-digit HEX code is three pairs, red, green and blue, each a number from 00 to FF in base 16. To turn a pair into its RGB value, multiply the first digit by 16 and add the second. The letters A–F stand for 10–15.

channel = (first digit × 16) + second digit
0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
A
10
B
11
C
12
D
13
E
14
F
15

Worked Example: Decoding #06B6D4

Step 1: Split into pairs

#06B6D4 → 06 · B6 · D4

Step 2: Convert each pair

06 = 0 × 16 + 6 = 6 · B6 = 11 × 16 + 6 = 182 · D4 = 13 × 16 + 4 = 212

rgb(6, 182, 212): almost no red, lots of green and blue, which makes a bright cyan. Reading the pairs as rough proportions tells you the color before you even convert it.

HEX Pairs at a Glance

Common pairs and how strong that channel is. The first digit does most of the work: 80 is half intensity, C0 three-quarters.

Common two-digit HEX pairs with their decimal value and intensity
PairDecimalIntensity
0000%
1A2610%
335120%
4D7730%
6610240%
8012850%
9915360%
B317970%
CC20480%
E623090%
FF255100%

3, 4, 6 and 8-Digit HEX Formats

The digit count tells you what's inside. Three and four digits are shorthand, where each digit is doubled. Six digits is plain RGB, and eight adds an alpha (opacity) pair.

HEX color formats with examples and where they are used
FormatExampleUsed in
#RGB#0BDCSS shorthand; each digit is doubled (#00BBDD)
#RRGGBB#06B6D4The standard form in CSS, design tools and brand guides
#RGBA#0BD8CSS shorthand with alpha
#RRGGBBAA#06B6D480CSS with alpha as the last pair
#AARRGGBB#8006B6D4Android and some Windows APIs: alpha comes first
0xRRGGBB0x06B6D4Code constants in C, Java, Python and others

Alpha: CSS vs Android Order

The alpha pair works like the color pairs: 00 is fully transparent, FF fully opaque and 80 about 50% (128 ÷ 255 = 0.502). The catch is where it goes. CSS puts alpha last (#RRGGBBAA), while Android color resources put it first (#AARRGGBB). So #8006B6D4 is a half-transparent cyan in Android, but in CSS the same eight digits mean a purple, rgb(128, 6, 182), at 83% opacity. When you paste an 8-digit code, choose the order it came from.

Will Text Be Readable on This Color?

Converting to RGB is also the first step in checking accessibility. The converter calculates each color's relative luminance from its RGB values and compares it with white and black text using the WCAG formula. WCAG level AA asks for at least 4.5:1 for normal text and 3:1 for large text.

The example cyan, #06B6D4, scores only 2.43:1 with white text, which fails, but 8.65:1 with black. Bright-looking colors often need dark text, even when white text "looks" fine at a glance.

Frequently asked questions

Are HEX codes case-sensitive?

No. #06b6d4 and #06B6D4 are the same color.

What does #FFF mean?

White: it's shorthand for #FFFFFF, rgb(255, 255, 255). Likewise #000 is black and #F00 is pure red.

How do I convert HEX to RGB in code?

Parse each pair as base 16. In JavaScript, parseInt("B6", 16) returns 182; in Python, int("B6", 16) does the same.

Why does my 8-digit color look wrong?

It probably came from Android or another system that puts alpha first (#AARRGGBB). Switch the order setting to Android to read it correctly.

Sources