HEX to RGB Color Converter

Convert HEX color codes to RGB and HSL with a live preview. Bidirectional conversion.

Free Live preview HEX ↔ RGB ↔ HSL
#0071e3

HEX

RGB

HSL

CSS values — click to copy
#0071e3
rgb(0, 113, 227)
hsl(211, 100%, 45%)
Quick swatches
Advertisement

Color format guide

HEX format

#RRGGBB — Six hexadecimal digits, two each for red, green, and blue. Range: #000000 (black) to #ffffff (white). Most common format in web design.

RGB format

rgb(R, G, B) — Three decimal values from 0–255. Red, green, blue. Supported in all browsers. Easy to understand and manipulate in code.

HSL format

hsl(H, S%, L%) — Hue (0–360°), Saturation (0–100%), Lightness (0–100%). More intuitive for color manipulation and generating color palettes.

HEX and RGB Colors — How Color Codes Work in CSS

Every color on your screen is made of three light components: red, green, and blue. HEX and RGB are simply two different ways to express the same three values. Understanding how they work makes you faster at working with colors in CSS, design tools, and code — no more guessing whether #ff0000 is red or blue.

Reading a HEX color code

A HEX color is six characters split into three pairs: #RRGGBB. Each pair is a hexadecimal number from 00 to FF (0 to 255 in decimal). #ff0000 — red is FF (255), green is 00, blue is 00. Pure red. #0071e3 — red is 00, green is 71 (113), blue is e3 (227). Apple's signature blue.

When to use HEX vs RGB vs HSL

HEX is the most compact and widely recognized — use it for fixed design values, especially when copying from Figma or Sketch. RGB is easier to manipulate mathematically and supports the rgba() syntax for transparency. HSL (Hue, Saturation, Lightness) is the most intuitive for generating color variations — adjusting only the lightness gives you tints and shades of the same hue without touching RGB values.

The 3-digit shorthand

When each pair of HEX digits repeats, you can use a 3-digit shorthand. #ffffff becomes #fff. #aabbcc becomes #abc. The browser expands it by doubling each digit. This only works when both digits in each pair are identical — #0071e3 cannot be shortened because none of its pairs repeat.

Frequently asked questions

How do I convert a HEX color to RGB?
Enter a HEX color code (like #0071e3 or 0071e3) in the HEX input field above. The RGB values are calculated and shown instantly. You can also click the color picker to select a color visually. The CSS rgb() value at the bottom is ready to copy into your stylesheet.
What is a HEX color code?
A HEX color code is a 6-character hexadecimal number preceded by # that represents an RGB color. The characters are split into three pairs: the first pair (00–FF) is the red value, the second pair is green, and the third is blue. For example, #ff0000 is pure red (R=255, G=0, B=0).
What is the difference between HEX and RGB color codes?
HEX and RGB represent exactly the same colors in different notations. HEX uses base-16 notation (#ff5733), while RGB uses base-10 decimal values (rgb(255, 87, 51)). Both produce identical colors in CSS and browsers. HEX is more compact; RGB is easier to read and manipulate mathematically.
How do I convert RGB to HEX color code?
Enter the R, G, B values in the RGB input fields (each between 0 and 255). The HEX code is calculated and displayed automatically in the HEX field. The CSS hex value is also shown in the copy section below, ready to paste into your code.
What is HSL color format and when should I use it?
HSL stands for Hue (0–360°), Saturation (0–100%), and Lightness (0–100%). It's more intuitive than RGB for humans because you can easily create color variations — increase lightness to make a color lighter, adjust saturation to make it more or less vivid. Great for programmatically generating color palettes and themes.
What does the # symbol mean in HEX colors?
The # symbol is simply a CSS/HTML prefix that tells the browser the following characters are a hexadecimal color value. The actual color data is in the 6 characters after the #. In some contexts (like JavaScript's canvas API or some design tools) you may omit the # and just use the 6 hex digits directly.