Hex to RGB Converter

Convert a hex color code to RGB or RGBA instantly — with the reverse RGB-to-hex formula explained.

—

Formula

Each hex pair converts to decimal: 4A = 4×16 + 10 = 74. rgb(red, green, blue) with values 0–255. Reverse: rgb → hex = value.toString(16), two digits per channel.

Examples

InputResult
#4A90D9rgb(74, 144, 217)
#F60 (3-digit)rgb(255, 102, 0)
#000000rgb(0, 0, 0)
#4A90D9, alpha 0.5rgba(74, 144, 217, 0.5)

Frequently Asked Questions

How does hex to RGB conversion work?

A 6-digit hex code is three two-digit base-16 numbers: pairs for red, green and blue. Convert each pair from hexadecimal to decimal and you have the RGB triplet. #4A90D9: 4A=74, 90=144, D9=217 → rgb(74, 144, 217).

What is a 3-digit hex code?

A shorthand where each digit is doubled: #F60 = #FF6600 = rgb(255, 102, 0). Browsers accept both.

How do I convert RGB back to hex?

Convert each channel to base 16 with two digits and concatenate: 74→4A, 144→90, 217→D9 gives #4A90D9 again. The formula is value.toString(16) in JavaScript.

When should I use rgba instead of rgb?

The fourth value is alpha (opacity) from 0 (transparent) to 1 (opaque) — useful for overlays and shadows. Enter any value between 0 and 1 above.

Related Calculators

Text to Binary ConverterPixels to Inches Converter