How HEX to RGB Conversion Works
A 6-digit HEX color code like #ff6347 is simply three 2-digit hexadecimal numbers concatenated: ff (red), 63 (green), 47 (blue). Hexadecimal (base 16) uses digits 0โ9 and letters AโF, where A=10, B=11, ..., F=15. To convert a 2-digit hex value to decimal: multiply the first digit by 16 and add the second. 'ff' = (15 ร 16) + 15 = 240 + 15 = 255. '63' = (6 ร 16) + 3 = 96 + 3 = 99. '47' = (4 ร 16) + 7 = 64 + 7 = 71. So #ff6347 = rgb(255, 99, 71) โ which is the CSS color 'tomato'. For 3-digit shorthand HEX (#f63), each digit is doubled: #f63 expands to #ff6633. This only works when each hex pair has identical digits โ it is a compression shortcut.
HEX vs RGB vs HSL โ When to Use Each in CSS
All three formats produce identical visual output in a browser โ the choice is about readability and use case: HEX is the most compact (7 characters including #) and is what every design tool exports by default. Use HEX when you want brevity or are pasting from Figma/Photoshop. RGB is best when you need to manipulate color values in JavaScript. Adding transparency is natural: rgba(255, 99, 71, 0.5) gives 50% opacity. You can also do math on channel values: darken a color by subtracting from each channel. HSL (hsl(hue, saturation%, lightness%)) is most human-readable for building color systems. To create a lighter variant of a color, just increase lightness: hsl(9, 100%, 50%) โ hsl(9, 100%, 70%). This makes theming and dark mode palettes much easier to maintain than calculating HEX variants manually.
Common HEX Colors and Their RGB Equivalents
Here are the colors web developers reach for most often: #ffffff = rgb(255, 255, 255) โ white #000000 = rgb(0, 0, 0) โ black #ff0000 = rgb(255, 0, 0) โ red #00ff00 = rgb(0, 255, 0) โ green (lime) #0000ff = rgb(0, 0, 255) โ blue #ffff00 = rgb(255, 255, 0) โ yellow #ff6347 = rgb(255, 99, 71) โ tomato #6c63ff = rgb(108, 99, 255) โ medium slate blue #1a1a2e = rgb(26, 26, 46) โ dark navy For any color not on this list, paste the HEX code into the Color Converter above to get the RGB and HSL values instantly.