HEX Color Codes Explained: How to Read, Write and Convert Them

Updated September 30, 2026 · 7 min read

HEX color codes are six-digit hexadecimal representations of RGB color, written in the form #RRGGBB. The first pair controls red, the second controls green, and the third controls blue, with each pair ranging from 00 to FF, equivalent to decimal values from 0 to 255. For example, #FF0000 means maximum red with no green or blue, producing pure RGB red.

What is a HEX color code?

A standard HEX color contains a hash followed by six hexadecimal characters: #RRGGBB.

The pairs represent red (RR), green (GG), and blue (BB).

Hexadecimal uses 16 symbols: 0 to 9 and then A to F.

00 is the minimum value for a channel and equals decimal 0. FF is the maximum and equals decimal 255.

Because there are 256 possibilities for each of three channels, six-digit HEX notation can represent 16,777,216 colors.

How to read a HEX color by eye

You can estimate a color by comparing its three pairs.

Consider #FF8000. Red is FF, so red is at maximum intensity. Green is 80, about halfway through its range, while blue is 00. You can therefore expect an orange color.

Now consider #2563EB. The blue pair EB is the largest channel. Green 63 contributes considerably less, while red 25 is relatively low. You can expect a strong blue.

When all three pairs are equal, as in #808080, the color is a neutral gray. The closer the pairs are to each other, the more muted the color.

For an exact conversion, enter the value into hex to rgb.

Ten common HEX colors

These basic values make the RGB structure easy to see:

  • White #FFFFFF
  • Black #000000
  • Red #FF0000
  • Lime #00FF00
  • Blue #0000FF
  • Yellow #FFFF00
  • Cyan or aqua #00FFFF
  • Magenta or fuchsia #FF00FF
  • Gray #808080
  • Orange #FFA500

HEX codes are case insensitive, so #FF0000, #ff0000, and #Ff0000 describe the same color.

Three-digit HEX shorthand

CSS supports a shorter three-digit form when both digits in each channel are identical.

#F00 expands to #FF0000. #FFF becomes #FFFFFF. #369 becomes #336699.

The shorthand does not reduce the precision of the expanded color. It is simply an alternative way of writing values where each channel contains a repeated digit.

Eight-digit HEX and alpha

HEX can also include an alpha channel: #RRGGBBAA.

The final AA controls opacity. 00 is fully transparent, while FF is fully opaque. Values between them provide partial transparency.

For example, #FF000080 is red at roughly 50 percent opacity. Four-digit shorthand #F008 also works.

HEX vs RGB

HEX and rgb() describe the same underlying sRGB color.

#FF0000 and rgb(255, 0, 0) both represent red.

RGB is easier when you want to understand or manipulate individual channel values numerically. HEX is compact and widely used for storing and communicating web colors.

Convert between them with hex to rgb and rgb to hex.

HEX vs HSL

HSL represents color through hue, saturation, and lightness.

That makes HSL easier when you want to create related variations of one color. Instead of independently modifying red, green, and blue channels, you change lightness while keeping the same hue and saturation.

Use hex to hsl when you want to inspect a HEX color in those terms.

CSS also supports newer color syntax such as oklch(), which keeps perceived lightness consistent across hues. You can explore that representation with the oklch converter.

Converting HEX to RGB by hand

Take the orange value #FFA500 and split it into FF (red), A5 (green), and 00 (blue).

Each hexadecimal pair converts to decimal by multiplying the first digit by 16 and adding the second.

FF equals 15 × 16 + 15 = 255.

For A5, A represents 10, so 10 × 16 + 5 = 165.

00 equals 0.

The result is rgb(255, 165, 0), which is the RGB definition of the CSS orange color.

CSS named colors

CSS provides 148 named colors.

Instead of writing a HEX value, you can use names such as red, blue, orange, navy, or rebeccapurple where CSS color syntax allows them.

Use the color name lookup to find the closest name for any HEX value, and the color names guide for how the naming lists differ.

Names are convenient for recognizable colors, but HEX and other numerical formats provide direct control over exact values.

HEX and wider-gamut web colors

Standard HEX notation represents sRGB colors.

It does not provide a way to encode colors outside the sRGB gamut by adding different HEX digits.

Modern CSS represents wider-gamut colors through other syntax, such as color(display-p3 1 0 0) or oklch().

This distinction matters on displays capable of showing colors beyond sRGB, which includes most current phones and laptops.

Why you should not send HEX as a print specification

HEX is an RGB screen-color representation, not a printing specification.

A commercial printer needs a production color defined according to the print workflow: process CMYK values under an appropriate ICC profile, or a specified spot color.

Use hex to cmyk for a profile-free reference conversion, but the actual CMYK conversion depends on the printer's ICC profile. RGB vs CMYK explains why the numbers move.

Do not assume a HEX color displayed on your monitor will print identically.

Picking and converting HEX colors

Use the color picker when you need to select a color and obtain its HEX value.

From there, hex to rgb converts it to RGB, while hex to hsl provides its hue, saturation, and lightness representation.

For print-oriented reference values, use hex to cmyk. For the nearest Pantone reference, use hex to pantone.

Choose the representation based on what you need to do with the color rather than treating one format as universally better.

FAQ

What does HEX mean in color?

HEX refers to hexadecimal notation for RGB color values. A standard code uses #RRGGBB, with two hexadecimal digits each for red, green, and blue.

How many colors can six-digit HEX represent?

Six-digit HEX can represent 16,777,216 combinations. Each red, green, and blue channel has 256 possible values from 00 through FF.

Is HEX different from RGB?

HEX and RGB notation represent the same sRGB color using different number systems. For example, #FF0000 and rgb(255, 0, 0) both represent red.

Can I use HEX colors for printing?

HEX should not be used as the final production specification for process printing. Use hex to cmyk for a reference conversion, then follow the printer's required CMYK profile or spot-color specification.