See exactly how hex color codes break down into Red, Green, and Blue binary channels — with full 8-bit binary representation for each component.
Every color you see on a screen is ultimately stored as a sequence of bits. When I first started working with graphics programming, the moment it clicked was when I realized that #FF5733 is not some magic code — it is just three bytes of binary data, one each for Red, Green, and Blue. The hex notation is just a more compact way to write those bytes.
A standard hex color code like #RRGGBB contains six hexadecimal digits. Each pair of digits represents one 8-bit channel. Since one hex digit holds exactly 4 bits, two hex digits make a full byte. The binary representation of each channel is straightforward: convert the hex pair to decimal, then write that decimal value as an 8-bit binary number.
During a design system overhaul, I had to programmatically parse thousands of hex color values from Figma export files. Being able to mentally convert #3366CC to its binary RGB components saved me from writing a separate parser.
In my day-to-day work building web tools, I find myself doing this conversion constantly — whether I am debugging a CSS color mismatch or packing pixel data for a canvas render. Understanding the binary behind the hex makes color manipulation far less mysterious.
Let us walk through the color #FF5733 step by step. This is a vivid orange-red shade. I use this color often in my projects because it demonstrates a nice range: one channel maxed out and two channels at mid-to-low values.
Putting it all together, the full 24-bit binary representation of #FF5733 is 11111111 01010111 00110011. That is exactly 24 bits — 8 per channel. Each time your GPU renders this color on screen, these 24 bits travel through the graphics pipeline.
When I need to convert a hex color to binary without a tool, I use a simple three-step method that I have developed over years of debugging pixel formats. It never fails and works for any 6-digit hex color.
A quick sanity check I always do: the leftmost bit of each binary byte tells you whether that channel value is 128 or higher. If the hex pair starts with 8 or above (8, 9, A-F), the binary byte starts with 1. This has saved me countless times when I am reading raw hex dumps from image files.
// JavaScript hex color to binary converter I use in dev tools:
function hexColorToBinary(hex) {
const r = parseInt(hex.slice(1,3), 16).toString(2).padStart(8, '0');
const g = parseInt(hex.slice(3,5), 16).toString(2).padStart(8, '0');
const b = parseInt(hex.slice(5,7), 16).toString(2).padStart(8, '0');
return `${r} ${g} ${b}`;
}
console.log(hexColorToBinary('#FF5733'));
// Output: "11111111 01010111 00110011"
Each RGB channel is an 8-bit value, giving us 256 possible intensities per channel (0-255). Three channels combined gives 256 × 256 × 256 = 16,777,216 possible colors. That is the full 24-bit true color space used by virtually every modern display.
Here is how those 16.7 million colors look at the bit level — the entire range fits into three bytes:
Notice something interesting about pure red, green, and blue: in each case, only one byte is fully set, and the other two bytes are all zeros. When you see a color like #FF00FF (magenta), you know the Red and Blue channels are fully on but Green is off — 11111111 00000000 11111111. Thinking in binary rather than hex makes these patterns immediately obvious.
True RGB color uses 24 bits, but many image formats and APIs store colors as 32-bit integers with an extra 8-bit alpha channel for transparency. The alpha byte simply prepends to make a 32-bit value: AA RR GG BB. Our ARGB bit operations guide covers this in detail.
Understanding the binary behind hex colors is just the start. Learn how to extract channels with masks, manipulate ARGB values, and work with different pixel formats.
To convert a hex color to binary, split the 6-digit hex code into three 2-digit pairs representing Red, Green, and Blue. Convert each pair from hex to decimal, then from decimal to 8-bit binary. For example, #FF5733 splits into R=FF (255 = 11111111), G=57 (87 = 01010111), B=33 (51 = 00110011).
The hex color #FF5733 in binary is: Red = 11111111 (255), Green = 01010111 (87), Blue = 00110011 (51). The full 24-bit binary representation is 11111111 01010111 00110011.
Hex is used because it is far more human-readable than binary. A 24-bit color value like 111111110101011100110011 takes 24 characters in binary but only 6 in hex (#FF5733). Each hex digit represents 4 bits, making it a compact notation that is still easy to work with programmatically.
Each RGB channel (Red, Green, Blue) ranges from 0 to 255, which is exactly the range of an 8-bit unsigned integer (00000000 to 11111111 in binary, or 00 to FF in hex). Three channels multiplied give 256^3 = 16,777,216 possible colors.
Yes. If you store a hex color as a 24-bit integer, you can extract each channel using bitwise AND and right shift: R = (color >> 16) & 0xFF, G = (color >> 8) & 0xFF, B = color & 0xFF. Each extracted byte can then be converted to binary.