The conversion, by hand
A hex color #RRGGBB is just three base-16 (hexadecimal) byte values concatenated — converting to RGB means splitting the string into three 2-character pairs and reading each as base-16:
#FF6B35
FF 6B 35
FFin hex = 15×16 + 15 = 2556Bin hex = 6×16 + 11 = 10735in hex = 3×16 + 5 = 53
So #FF6B35 = rgb(255, 107, 53). Each pair is exactly one byte (0–255), which is why hex color codes are always 6 digits for full RGB — 2 hex digits per channel, 3 channels.
The 3-digit shorthand
#F63 is shorthand for #FF6633 — each digit is duplicated, not padded with a zero. This is why the shorthand can only represent 16 possible values per channel (0, 17, 34, ... 255) instead of the full 256 — it's a strict subset of colors, not an approximation of arbitrary ones.
#F63 → F→FF, 6→66, 3→33 → #FF6633
Why this conversion is always exact, never lossy
Hex and RGB describe the identical underlying value — one in base 16, one in base 10 — so converting between them loses no information whatsoever; it's a pure notation change, not a transformation of the color itself. This differs from converting to HSL, where the underlying numbers involved are genuinely different (hue/saturation/lightness are calculated from RGB via trigonometric-adjacent formulas, not just re-expressed).
Common mistakes
- Confusing the 3-digit shorthand with a padded 6-digit value.
#F63is not#0F0603or similar zero-padding — each digit doubles to fill both positions of its channel. - Manually converting hex to decimal incorrectly. A common slip is treating hex digits as base-10 place values instead of base-16 — remember each position represents a power of 16, not 10.
- Assuming hex-to-RGB conversion can introduce rounding error. It can't — both represent the exact same integer values in different bases; any rounding concerns only appear when converting to a genuinely different color space like HSL.
FAQ
Does converting hex to RGB ever lose precision?
No — they represent identical values in different number bases; the conversion is exact in both directions.
How is the 3-digit hex shorthand expanded to 6 digits?
Each digit is duplicated, not zero-padded — #F63 becomes #FF6633, not #0F0603.
Why are hex codes always exactly 6 digits (or 3 in shorthand)?
Because each color channel (red, green, blue) needs exactly 2 hex digits to represent its full 0–255 range — 3 channels × 2 digits = 6.
Convert between HEX, RGB, and HSL instantly with the Color Palette Extractor — runs entirely in your browser.