Color tools

HEX to RGB converter

Paste any hex code — with or without #, 3, 4, 6 or 8 digits — and get RGB and RGBA as you type. It runs in your browser; nothing is sent anywhere.

RGB
⇄ RGB to HEX

Other ways to write it

All formats

Name and Tailwind

Contrast (WCAG)

Text on white
Text on black

How hex becomes RGB

A hex code is three numbers written in base 16, two digits each: red, green, blue. Each pair is first digit × 16 + second digit, where A–F are 10–15. The result is 0–255, the same range rgb() uses. With eight digits, the last two are alpha.

This walkthrough follows the color in the converter.

#3B82F6

Hex to RGB colors: common values

Click a row to load it into the converter.

Color HEX RGB
Black #000000 rgb(0, 0, 0)
White #FFFFFF rgb(255, 255, 255)
Red #FF0000 rgb(255, 0, 0)
Lime #00FF00 rgb(0, 255, 0)
Blue #0000FF rgb(0, 0, 255)
Yellow #FFFF00 rgb(255, 255, 0)
Cyan #00FFFF rgb(0, 255, 255)
Magenta #FF00FF rgb(255, 0, 255)
Silver #C0C0C0 rgb(192, 192, 192)
Gray #808080 rgb(128, 128, 128)
Maroon #800000 rgb(128, 0, 0)
Olive #808000 rgb(128, 128, 0)
Green #008000 rgb(0, 128, 0)
Purple #800080 rgb(128, 0, 128)
Teal #008080 rgb(0, 128, 128)
Navy #000080 rgb(0, 0, 128)

Hexadecimal to RGB color code: questions

How do I convert a hex color code to RGB?

Split the six digits into three pairs — red, green, blue — and read each pair as a base-16 number: first digit × 16 + second digit, where A–F are 10–15. #3B82F6 is 3B = 59, 82 = 130, F6 = 246, so rgb(59, 130, 246). The walkthrough above does this for whatever you type.

What about 3-digit hex like #fff?

It's shorthand: each digit is doubled. #fff is #ffffff, which is rgb(255, 255, 255); #f80 is #ff8800. The converter accepts 3, 4, 6 and 8 digits, with or without the #.

What does an 8-digit hex code mean?

The last two digits are alpha (opacity), from 00 (transparent) to FF (opaque). #3B82F680 is rgba(59, 130, 246, 0.502): 80 in hex is 128, and 128 / 255 ≈ 0.502.

Should I write rgb() or rgba()?

In current CSS they're the same function: rgb(59 130 246 / 0.5) and rgba(59, 130, 246, 0.5) both work in every current browser. The comma form is the one older tools and design apps expect; copy whichever your codebase uses.

Is hex to RGB conversion exact?

Yes. Hex and RGB are two spellings of the same sRGB numbers, so nothing is rounded. Converting to HSL, HSV, CMYK or OKLCH does round; those values are shown to one decimal.

Chrome extension

Got the color from a web page?

Pick it straight off any page with KD Color: HEX, RGB, HSL and OKLCH in one click.

Add to Chrome

Color API

Do it in code

curl "https://color.koval.tools/v1/convert?value=%233B82F6"

One call returns HEX, RGB, HSL, HSV, CMYK, Lab, LCH and OKLCH. No key needed to try it. Convert docs · Pricing

More converters

All converters · All color tools