Skip to content
hexcolorcodepicker.com

What Is a HEX Color Code?

What is a HEX color code?

A HEX color code is a 6-digit code that names one exact color for a screen. It starts with a hash sign, then 6 letters or numbers, such as #FF5733. The code tells a browser or design tool how much red, green, and blue light to mix.

HEX stands for hexadecimal, which is a base-16 number system. It uses the digits 0 to 9 and the letters A to F, where A means 10 and F means 15. Each color is built from 3 pairs of hex digits, one pair for red, one for green, and one for blue. That is why the code is written as #RRGGBB, with RR for red, GG for green, and BB for blue.

#FF5733

Tap a block to highlight that channel and see its decimal value on a 0-to-255 bar.

How to read #RRGGBB, pair by pair

Read a HEX code as 3 pairs: the first pair is red, the second pair is green, and the third pair is blue. Each pair runs from 00, which means none of that color, to FF, which means the full amount of that color.

The pair 00 equals 0 in decimal, and the pair FF equals 255 in decimal. A pair in the middle, such as 80, equals 128, which is about half strength. So #FF0000 is pure red, #00FF00 is pure green, and #0000FF is pure blue, because only one channel is at full strength. A code such as #808080 has all 3 channels at 128, so it is a medium gray with no color at all.

Worked examples

#FF5733 is rgb(255, 87, 51), a bright orange-red. The red pair FF equals 255, the green pair 57 equals 87 (5 times 16 plus 7), and the blue pair 33 equals 51 (3 times 16 plus 3). Red is at full strength, green is about one third, and blue is about one fifth, so the result is a warm orange-red.

#3B82F6 is rgb(59, 130, 246), a bright blue. The red pair 3B equals 59 (3 times 16 plus 11), the green pair 82 equals 130 (8 times 16 plus 2), and the blue pair F6 equals 246 (15 times 16 plus 6). Blue is nearly full, green is about half, and red is low, so the result is a clear blue used by many websites.

#FF5733 · rgb(255, 87, 51)

Move a slider: the swatch, the full HEX code, and the RGB numbers update together.

Why 16,777,216 colors?

A 6-digit HEX code can name 16,777,216 colors, because each of the 3 channels has 256 possible values. That is 256 times 256 times 256, which equals 16,777,216. Every code is one exact mix of red, green, and blue.

Each pair has 2 hex digits, and each digit has 16 possible values, so one pair has 16 times 16, or 256, values from 00 to FF. Three channels at 256 values each give 256 times 256 times 256. That count is often rounded to 16.7 million colors. It matches the 24-bit color depth used by most screens, where each channel gets 8 bits.

16 values

One hex digit: 0 to F.

Each step multiplies the colors: 16, then 256, then 65,536, then 16,777,216.

The 3-digit shorthand: #RGB

A 3-digit HEX code is a short form where each digit is doubled to make the full 6-digit code. The code #F53 means #FF5533, because F becomes FF, 5 becomes 55, and 3 becomes 33. It is the same color, written shorter.

Shorthand works only when each pair has two matching digits, such as #FFF for white, #000 for black, and #F00 for pure red. A code such as #FF5733 cannot be shortened, because its pairs are 57 and 33, not doubles. Shorthand can name only 4,096 colors, because it has 3 digits at 16 values each, which is 16 times 16 times 16. See our guide on 3-digit HEX codes for the full shorthand rules and the common mistakes.

Only 4,096 of the 16,777,216 colors can be written this way.

Each digit doubles into its pair: F → FF, 5 → 55, 3 → 33.

What about transparency? The 8-digit form

An 8-digit HEX code adds a fourth pair for alpha, which sets transparency. The form is #RRGGBBAA, where AA runs from 00 for fully transparent to FF for fully solid. The code #3B82F680 is blue at 50 percent opacity.

The alpha pair uses the same 00-to-FF range as the color pairs, so 80 means about half transparent and BF means about 75 percent solid. CSS also writes the same idea as rgba(59, 130, 246, 0.5). Some systems put alpha first instead, as #AARRGGBB, which is common in Android and Flutter code. See our guide on 8-digit HEX codes and transparency for the full alpha table and the alpha-first form.

#3B82F680 · rgba(59, 130, 246, 0.5)

Move the slider: the alpha pair, the rgba() value, and how much checkerboard shows through all update.

A short history: from CGA to 24-bit color

Screens started with a few fixed colors and grew to 24-bit color, where any of 16,777,216 colors can be shown. Early CGA screens showed 4 colors at once, EGA showed 16, and VGA showed 256, before 24-bit color made every HEX code possible.

Each step added more bits per pixel, so more colors could be stored and shown. VGA's 256 colors came from a fixed palette, while 24-bit color stores 8 bits for red, 8 for green, and 8 for blue, which is exactly the 3 pairs of a HEX code. The sRGB standard then fixed what those numbers mean on a screen, so #FF0000 looks like the same red on different displays.

4 colors

2 bits per pixel, 1981.

Tap a step to see its palette and its bit depth.

Where HEX codes are used

HEX codes are used in CSS, HTML, design tools, and brand guides to name exact colors. A web developer writes color: #3B82F6; in CSS, a designer pastes the same code into Figma, and a brand guide lists it so every page uses the same blue.

HEX is the web default because it is short, exact, and easy to copy. RGB is the same color in a different form, and HSL is better when you want to lighten or darken a color, but the color itself does not change. Use the Hex Color Code Picker to find a code, copy it with one tap, and paste it into your code or design tool. Always check contrast before using a color for text, because a pretty color can still be hard to read.

  1. 1Pick a color on the homepage picker — here, #3B82F6.
  2. 2Copy its HEX code with one tap.
  3. 3Paste it into CSS:color: #3B82F6;

Each card shows the same #3B82F6 swatch. Tap the copy card to copy the code.

Frequently asked questions

HEX stands for hexadecimal, a base-16 number system. It uses the digits 0 to 9 and the letters A to F, where A is 10, B is 11, C is 12, D is 13, E is 14, and F is 15. A HEX color code uses that system to store 3 color values in 6 digits.