Color Conversion Utility

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.

#3B82F6 Adaptive Text Contrast
HEX Code (6 / 8 Digit)
#3B82F6
Modern CSS Color 4
rgb(59 130 246)
HSL String
hsl(217, 91%, 60%)
Step-by-Step Decimal to Hexadecimal Conversion:

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:

  1. 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$$
  2. 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
  3. 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.

6. Related Developer Utilities