Hex Color to Binary Converter

See exactly how hex color codes break down into Red, Green, and Blue binary channels — with full 8-bit binary representation for each component.

Color palette visualization for hex to binary web color conversion
Hex Color to Binary Example: #FF5733 Manual Conversion 24-Bit Color FAQ

How Hex Colors Map to Binary

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.

Hex Color Structure: #RRGGBB
#FF5733

FF = Red channel   (hex FF = decimal 255 = binary 11111111)
57 = Green channel (hex 57 = decimal 87  = binary 01010111)
33 = Blue channel  (hex 33 = decimal 51  = binary 00110011)

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.

#FF5733 — Worked Binary Breakdown

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.

Red Channel: FF (255)

Hex FF Binary 11111111
Hex FF = 15×16 + 15 = 255
Binary: 11111111 (all 8 bits set to 1)
Result: Red is fully on — all bits are 1.
This is maximum red intensity: 255 out of 255.

Green Channel: 57 (87)

Hex 57 Binary 01010111
Hex 57 = 5×16 + 7 = 87
Binary breakdown:
87 - 64 = 23  (bit 6 = 1)
23 - 16 = 7   (bit 4 = 1)
7 - 4 = 3     (bit 2 = 1)
3 - 2 = 1     (bit 1 = 1)
1 - 1 = 0     (bit 0 = 1)
Binary: 01010111
Green is at roughly 34% intensity (87/255).

Blue Channel: 33 (51)

Hex 33 Binary 00110011
Hex 33 = 3×16 + 3 = 51
Binary breakdown:
51 - 32 = 19  (bit 5 = 1)
19 - 16 = 3   (bit 4 = 1)
3 - 2 = 1     (bit 1 = 1)
1 - 1 = 0     (bit 0 = 1)
Binary: 00110011
Blue is at 20% intensity (51/255).

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.

Manual Hex-to-Binary Conversion Method

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.

Three-Step Conversion (Example: #A5D6F7)
Step 1 — Split into pairs: A5 | D6 | F7
Step 2 — Convert each pair to decimal:
  A5 = 10×16 + 5 = 165
  D6 = 13×16 + 6 = 214
  F7 = 15×16 + 7 = 247
Step 3 — Convert each decimal to 8-bit binary:
  165 = 10100101
  214 = 11010110
  247 = 11110111
Result: 10100101 11010110 11110111

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"

24-Bit Color and the Full Color Space

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:

Selected Colors in Binary
#000000 (black):   00000000 00000000 00000000
#FFFFFF (white):   11111111 11111111 11111111
#FF0000 (red):     11111111 00000000 00000000
#00FF00 (green):   00000000 11111111 00000000
#0000FF (blue):    00000000 00000000 11111111
#808080 (gray):    10000000 10000000 10000000

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.

24-Bit vs 32-Bit Color

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.

Explore More Color Bit Operations

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.

Frequently Asked Questions About Hex Color to Binary Conversion

How do you convert a hex color to binary?

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).

What does the hex color #FF5733 look like in binary?

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.

Why is hex commonly used for colors instead of binary?

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.

What is the range of values for each RGB channel?

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.

Can I convert hex colors back to binary using bitwise operations?

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.

Related Tools

Bitwise Calculator →

AND, OR, XOR, NOT, shifts

Bitwise Guide →

Complete operations reference

Hex to ASCII →

Decode hex strings

SHA256 Generator →

Compute hashes