ToolMint
converters5 min readMay 13, 2026

HEX to RGB Color Conversion โ€“ Formula, Examples & CSS Guide

Web designers and developers constantly work with HEX color codes (#ff6347) and RGB values (rgb(255, 99, 71)) โ€” two ways of expressing exactly the same color. Understanding the relationship between them lets you read and modify colors mentally, debug CSS issues faster, and choose the right format for different use cases. This guide covers the conversion formula, examples, and practical CSS context.

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.

Try the tools mentioned in this guide

Frequently Asked Questions

How do I convert HEX to RGB manually?
Split the 6-digit HEX into three pairs. Convert each pair from hexadecimal to decimal: multiply the first digit by 16 and add the second. Example: #1a2b3c โ†’ R=1ร—16+10=26, G=2ร—16+11=43, B=3ร—16+12=60 โ†’ rgb(26, 43, 60).
What is the difference between #abc and #aabbcc?
They are the same color written two ways. 3-digit HEX is a shorthand where each digit is doubled: #abc = #aabbcc. This only works when both digits in each pair are identical.
Can I use HEX colors with transparency in CSS?
Yes. CSS supports 8-digit HEX with an alpha channel: #ff634780 is tomato at 50% opacity (80 in hex = 128 in decimal รท 255 โ‰ˆ 50%). Alternatively use rgba(255, 99, 71, 0.5) which is more readable.
What is the HEX code for white and black?
#ffffff is white (all channels at maximum 255). #000000 is black (all channels at 0). The shorthand forms are #fff and #000.

Related Guides