HEX to RGB Converter

Convert a HEX color code to RGB and HSL, or go the other way, with a live preview.

HEX–
CSS rgb()–
CSS hsl()–
Best text color on it–

How HEX color codes work

A HEX color code such as #0F766E describes a color as three pairs of hexadecimal (base-16) digits: one pair each for red, green and blue. Each pair runs from 00 (0) to FF (255), so HEX and RGB are two ways of writing exactly the same values.

How to convert HEX to RGB by hand

  1. Split the code into pairs: 0F 76 6E.
  2. Convert each pair from base 16 to base 10: the first digit × 16 plus the second digit, where A=10, B=11 … F=15.
  3. 0F = 0×16 + 15 = 15, 76 = 7×16 + 6 = 118, 6E = 6×16 + 14 = 110.

So #0F766E = rgb(15, 118, 110). To go from RGB to HEX, divide each value by 16: the whole number is the first digit and the remainder is the second.

Short HEX and alpha

  • 3-digit HEX doubles each digit: #F60 = #FF6600.
  • 8-digit HEX adds an alpha (opacity) pair at the end: #0F766E80 is about 50% opaque. This converter reads the color and ignores the alpha.

What is HSL?

HSL stands for hue, saturation and lightness, and it is often easier for people to adjust than RGB:

  • Hue (0–360°) is the position on the color wheel: 0 red, 120 green, 240 blue.
  • Saturation (0–100%) runs from gray to full color.
  • Lightness (0–100%) runs from black, through the pure color at 50%, to white.

To make a lighter or darker shade of a brand color, keep hue and saturation and change only lightness.

Readable text: contrast ratio

The "best text color" result uses the WCAG contrast formula to tell you whether white or black text is more readable on your color. WCAG recommends a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text.

Common colors

ColorHEXRGB
White#FFFFFF255, 255, 255
Black#0000000, 0, 0
Red#FF0000255, 0, 0
Green (CSS "lime")#00FF000, 255, 0
Blue#0000FF0, 0, 255
Gray#808080128, 128, 128

Frequently asked questions

How do I convert HEX to RGB?

Split the six digits into three pairs and convert each from hexadecimal to decimal. #FF8000 becomes rgb(255, 128, 0).

Are HEX and RGB the same color?

Yes. They are two notations for the same red, green and blue values, so the color is identical.

What does a 3-digit HEX code mean?

Each digit is doubled. #ABC is the same as #AABBCC.

Which is better for CSS, HEX or HSL?

Both work in all modern browsers. HEX is compact and common in design tools. HSL makes it easy to create lighter or darker variations of a color.

Last updated December 2, 2026.