How to Convert HEX to RGB Color Codes

· 5 min read

HEX and RGB are two ways of writing the exact same colors. Designers and developers switch between them constantly: HEX in CSS stylesheets, RGB in JavaScript animations, HSL in design tools. Understanding how they relate makes color work much easier. A converter handles the mental arithmetic so you can focus on getting the color right, not on base-16 division.

How HEX colors work

A HEX color code like #FF5733 is a 6-digit hexadecimal number that represents red, green, and blue channels:

Part Hex Decimal Channel
FF FF 255 Red
57 57 87 Green
33 33 51 Blue

Each channel ranges from 00 (0, no color) to FF (255, full intensity). So #FF5733 means full red, some green, a little blue, which gives you a warm orange-red.

How to convert HEX to RGB

  1. Enter your HEX code: type or paste a color code like #FF5733 or use the color picker.
  2. View the RGB values: see the equivalent red, green, and blue values (0-255 each).
  3. Copy in any format: grab the values as rgb(255, 87, 51), individual channels, or other formats like HSL.

A brief history of color codes on the Web

Color in early web browsers (Mosaic 1993, Netscape 1994) used named colors only: red, blue, green. The HTML 3.2 spec (1997) introduced hexadecimal color codes via the BGCOLOR attribute, and CSS 1 (1996) made them universal. The choice of HEX over decimal was practical: a 6-character HEX code is shorter than rgb(255, 87, 51) and easier to copy-paste from a color picker.

The RGB color model itself is much older. James Clerk Maxwell demonstrated in 1861 that any color visible to the human eye can be created by mixing red, green, and blue light. Television (1930s) and computer monitors (1970s) used this principle directly: each pixel is three sub-pixels (one red, one green, one blue) at different brightnesses.

Modern CSS (2010 onward) added many more color formats: hsl() (hue, saturation, lightness), hwb() (hue, whiteness, blackness), lab() (perceptually uniform), lch(), oklab(), oklch(), and color() for arbitrary color spaces. All represent the same colors as HEX/RGB but with different mental models. HEX persists because it is dense, copy-pasteable, and easy to share.

Manual conversion: how to do it in your head

You do not need a tool to convert simple HEX values. The trick is knowing the powers of 16:

For a HEX pair like 5A: the first digit times 16 plus the second digit. 5A = 5 × 16 + 10 = 90.

For shortcuts:

The pairs 33, 66, 99, CC (in any combination) produce the classic "web-safe" 216-color palette from the 1990s. They appear constantly in designer mood boards even today.

Common color codes

Color HEX RGB
White #FFFFFF rgb(255, 255, 255)
Black #000000 rgb(0, 0, 0)
Red #FF0000 rgb(255, 0, 0)
Green #00FF00 rgb(0, 255, 0)
Blue #0000FF rgb(0, 0, 255)
Yellow #FFFF00 rgb(255, 255, 0)
Cyan #00FFFF rgb(0, 255, 255)
Magenta #FF00FF rgb(255, 0, 255)
Tailwind slate-900 #0F172A rgb(15, 23, 42)
Tailwind blue-500 #3B82F6 rgb(59, 130, 246)
Material indigo 500 #3F51B5 rgb(63, 81, 181)
GitHub button green #2EA44F rgb(46, 164, 79)

HEX with alpha (8-digit HEX)

CSS 4 (2017) introduced 8-digit HEX with an alpha channel. #FF5733CC is rgb(255, 87, 51) with 80% opacity (CC in hex = 204, divided by 255 = 0.80).

Browser support is universal in modern browsers (Chrome 62+, Firefox 49+, Safari 9.1+, Edge 79+). For new projects, 8-digit HEX is a clean alternative to rgba(). For older projects, stick with rgba() for backward compatibility.

A short 4-digit HEX also exists: #F80C is the same as #FF8800CC. Same shorthand rules as 3-digit HEX.

Use cases for each format

Use HEX when:

Use RGB when:

Use HSL when:

Use OKLCH when:

Common pitfalls

Tips

Privacy

The HEX-to-RGB converter runs entirely in your browser. The colors you enter, your custom palettes, and any saved values stay on your device. This matters less than for file-conversion tools (a color code is not personally sensitive), but it does matter for design-confidentiality reasons: the colors you are experimenting with may reveal unannounced brand directions, client work under NDA, or product theming in development. Browser-only computation has zero exposure.

Frequently Asked Questions

How do I convert HEX to RGB manually?

Split the 6-digit hex code into three pairs (e.g.,

What about 3-digit HEX codes?

Three-digit hex is shorthand where each digit is doubled.

When should I use HEX vs RGB?

HEX is more compact and widely used in CSS. RGB is better when you need to manipulate individual color channels programmatically or use rgba() for transparency. Both represent the same colors.

What is the

The hash (#) is a prefix that identifies the value as a hexadecimal color code. It is not part of the color value itself. Some tools accept HEX codes with or without the hash.