Fast 3-Channel Converter • Bitwise Accurate

RGB to HEX Color Converter

Convert integer Red, Green, Blue (0–255) color values into standard 6-character Hexadecimal (#RRGGBB) codes with real-time contrast scoring, reciprocal HEX parsing, and code export.

RGB to HEX RGBA to HEX (With Alpha) HEX to RGBA

RGB Channel Inputs (0–255)

0–255
0–255
0–255
White Text: 3.4:1 (AA Large) Black Text: 6.1:1 (AAA)
Sample Interface Typography
Luminance: 0.23
Resulting Hexadecimal Code
#3B82F6

Ready-to-Use Code Snippets

CSS Stylesheet color: #3b82f6; /* rgb(59, 130, 246) */
JavaScript / TypeScript const brandColor = '#3B82F6';
Python / Pillow rgb = (59, 130, 246) # hex: '#3B82F6'
SwiftUI (iOS & macOS) Color(red: 59/255, green: 130/255, blue: 246/255)

How RGB to Hexadecimal Conversion Works

In computer graphics and web design, color is represented in two primary notations: the decimal RGB model (base 10) and the Hexadecimal notation (base 16).

The Conversion Math Formula

Each RGB channel ranges from 0 to 255 ($2^8 = 256$ possibilities). In hexadecimal, 256 states are represented by exactly two digits ($16 \times 16 = 256$) from 00 to FF.

HEX = # + Hex(Red) + Hex(Green) + Hex(Blue)

Step-by-Step Calculation Example

For rgb(59, 130, 246):

  • Red: $59 \div 16 = 3$ remainder $11$ (B) $\rightarrow$ 3B
  • Green: $130 \div 16 = 8$ remainder $2$ $\rightarrow$ 82
  • Blue: $246 \div 16 = 15$ (F) remainder $6$ $\rightarrow$ F6
  • Result: #3B82F6

Popular RGB & Hexadecimal Color Codes

Quick reference table of essential designer and web-safe RGB values with corresponding 6-character hex strings:

Color Name Color Preview RGB Values Hexadecimal Code HSL Equivalent
Deep Forest Green rgb(27, 67, 50) #1B4332 hsl(155°, 43%, 18%)
Electric Blue rgb(59, 130, 246) #3B82F6 hsl(217°, 91%, 60%)
Sun Yellow rgb(255, 222, 56) #FFDE38 hsl(50°, 100%, 61%)
Pale Slate rgb(217, 226, 236) #D9E2EC hsl(212°, 33%, 89%)
Pure White rgb(255, 255, 255) #FFFFFF hsl(0°, 0%, 100%)
Deep Obsidian (Black) rgb(10, 11, 14) #0A0B0E hsl(225°, 17%, 5%)

Frequently Asked Questions: RGB to HEX

What is the difference between RGB and HEX color codes?

RGB uses three base-10 integer values from 0 to 255 representing red, green, and blue light (e.g. rgb(59, 130, 246)). HEX condenses those same three numbers into a compact base-16 string with a leading hash (e.g. #3B82F6). Both produce identical visual colors.


Can RGB have transparency or alpha channels?

Standard RGB only contains 3 color channels. If you need opacity or transparency, you should use RGBA (Red, Green, Blue, Alpha). You can use our RGBA to HEX Converter to convert opacity into 8-character hex codes (e.g. #3B82F6D9).


Are HEX codes case-sensitive in CSS?

No. In CSS and HTML, hexadecimal color strings are completely case-insensitive. #3b82f6 and #3B82F6 render identically across all modern browsers.

Explore More Color Tools

Generate 11-step color scales, harmony palettes, or inspect screenshots with an 8x loupe.

Tint & Shade Generator Interactive Color Wheel Image Color Picker Safari Color Picker