Beginner

HEX to RGB Color Converter

Turn any hex color code into its red, green and blue channel values and a ready-to-paste CSS rgb() string.
Accepts #RGB or #RRGGBB
CSS color
rgb(59, 130, 246)
14%
30%
57%
R 59
G 130
B 246
Red / Green / Blue channel mix (0–255 each)
Red (R)
59
Green (G)
130
Blue (B)
246
Normalized hex
#3b82f6
Step by step
  1. 1

    Red channel

    3 × 16 + 11 = 59
  2. 2

    Green channel

    8 × 16 + 2 = 130
  3. 3

    Blue channel

    15 × 16 + 6 = 246
    Each 2-digit hex pair converts to decimal as: high digit × 16 + low digit.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

A hex color converts to RGB by stripping the "#", expanding 3-digit shorthand to 6 digits, then reading each pair of hex digits as a base-16 number from 0 to 255 for red, green and blue. Those three values form the CSS string rgb(R, G, B) used directly in stylesheets.

Formula
R = hex[0:2]₁₆, G = hex[2:4]₁₆, B = hex[4:6]₁₆ → rgb(R, G, B)
How this is calculated

Enter a hex color either as a 6-digit code (#RRGGBB) or its 3-digit shorthand (#RGB). The converter first removes the leading "#". If only three digits are supplied, each digit is doubled, so #abc expands to #aabbcc — this keeps the shorthand and full forms visually identical.

The six hex digits are then split into three pairs. Each pair is a base-16 (hexadecimal) number that is parsed into a base-10 integer between 0 and 255: R from the first pair, G from the second, and B from the third. Because two hex digits range from 00 to FF, every channel maps cleanly onto the 0–255 range used by CSS and most display systems.

The three channel values are assembled into a CSS string of the form rgb(R, G, B). Input is validated to contain only the characters 0–9 and a–f (case-insensitive) and to be exactly 3 or 6 digits after stripping the "#"; anything else is rejected so you never get a half-parsed color.

Frequently asked questions

They describe the same color space. The 3-digit shorthand simply repeats each digit, so #f0c is identical to #ff00cc. Use shorthand only when each channel uses a repeated digit.

No. Hex digits A–F and a–f represent the same values, so #FF8800 and #ff8800 convert to the same rgb(255, 136, 0).

Two hexadecimal digits span 00 to FF, which equals 0 to 255 in decimal. That 8-bit range is the standard precision for each color channel on screens.

Also known as

hex to rgb
hex to rgb converter
hex color to rgb
color code converter
css color
convert hex to rgb
hex code to rgb
html color converter

APA

TG we-Calculate Editorial Team. (2026). HEX to RGB Color Converter [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/hex-to-rgb-color-converter

Chicago

TG we-Calculate Editorial Team. "HEX to RGB Color Converter." TG we-Calculate. 2026. https://we-calculate.com/calculator/hex-to-rgb-color-converter.

IEEE

TG we-Calculate Editorial Team, "HEX to RGB Color Converter," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/hex-to-rgb-color-converter

BibTeX

@misc{wecalculate_hex_to_rgb_color_converter, title = {HEX to RGB Color Converter}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/hex-to-rgb-color-converter}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?