RGB & RGBA to HEX Converter
Convert Red, Green, Blue, and Alpha decimal values into standard 6-digit and 8-digit Hexadecimal color codes with bulk batch processing.
1. The Mechanics of Decimal to Hexadecimal Color Encoding
Digital computer monitors, mobile displays, and TV panels render colors using the additive RGB light model. By modulating Red, Green, and Blue sub-pixel intensities across 256 discrete levels (integers 0 through 255), screens produce over 16.7 million distinct hues ($256^3$).
In CSS stylesheets and design tokens, these coordinates are expressed as decimal integers (rgb(59, 130, 246)) or base-16 hexadecimal notation (#3B82F6). When an Alpha transparency channel is present, CSS Color Module Level 4 supports 8-digit HEX syntax (e.g. #3B82F6CC), encoding both color and opacity into a compact string.
2. Decimal to Base-16 Conversion Matrix
| Decimal Intensity (0-255) | Hexadecimal Pair | Relative Channel Saturation |
|---|---|---|
0 |
00 |
0% (Channel completely off) |
64 |
40 |
25% Quarter intensity |
128 |
80 |
50% Half intensity |
192 |
C0 |
75% Three-quarter intensity |
255 |
FF |
100% Maximum light emission |
3. The Mathematics of Converting Decimal RGB to HEX
To convert an 8-bit integer channel (0 to 255) to a two-character hexadecimal pair manually:
- Divide by 16: Divide the decimal value by 16 to find the integer quotient and remainder. For example, for Red = $59$: $$59 \div 16 = 3 \quad \text{remainder} \quad 11$$
- Map to Hexadecimal Characters: Digits 0โ9 stay as numbers, while remainders 10โ15 map to letters AโF ($10=\text{A}, 11=\text{B}, 12=\text{C}, 13=\text{D}, 14=\text{E}, 15=\text{F}$).
- Quotient $3 \rightarrow$
3 - Remainder $11 \rightarrow$
B
- Quotient $3 \rightarrow$
- Combine the Pair: Concatenating both yields
3B. Repeating for Green ($130 \rightarrow 82$) and Blue ($246 \rightarrow \text{F6}$) produces the final string:#3B82F6.
4. Client-Side Execution & Privacy Guarantee
All color transformations, base-16 conversions, and batch parsing execute locally in your web browser sandbox using client-side JavaScript. Proprietary brand colors, internal design tokens, and stylesheet files are never uploaded or stored on remote servers.
5. Frequently Asked Questions
What is the difference between 6-digit and 8-digit HEX codes?
A 6-digit hex code (#RRGGBB) specifies Red, Green, and Blue channels at 100% opacity. An 8-digit hex code (#RRGGBBAA) appends two extra characters representing the Alpha transparency channel from 00 (fully transparent) to FF (fully opaque).
What is modern CSS Color Module Level 4 syntax?
CSS Color 4 unifies color functions by using space-separated arguments instead of commas, and a forward slash for alpha opacity: rgb(59 130 246 / 0.8) instead of legacy rgba(59, 130, 246, 0.8).
Can I convert a batch of colors at once?
Yes. Select the Batch Bulk Converter tab above to paste multiple rgb() or rgba() strings. The engine parses all values in parallel and generates corresponding HEX rules.