CalculatorsConvertersDeveloperTextAll toolsDirectory
Submit your tool Sign in
Theme
Home/Answers/Developer
How-to

How do I convert a hex color to RGB?

Short answer

Paste a hex color like #3498db into a browser-based converter and it returns the RGB values, in this case rgb(52, 152, 219). The conversion runs on your device by reading the three pairs of hex digits as the red, green and blue channels, and it works both ways so you can go from RGB back to hex too.

A hex color is just three bytes

A six-digit hex color encodes three bytes: the first pair is red, the second green, the third blue, each ranging from 00 to FF, which is 0 to 255 in decimal. So #3498db splits into 34, 98 and db, which convert to 52, 152 and 219, giving rgb(52, 152, 219). A three-digit shorthand like #abc simply doubles each digit into #aabbcc.

Why you keep needing both formats

Hex is compact and standard in design tools and CSS, while RGB and the related rgba are needed when you want to add an alpha channel for transparency or manipulate a channel in code. Converting between them is a constant small task in front-end work, and a two-way converter means you never have to do the base-16 math in your head.

Step by step

  1. Paste the hex color. Enter a hex color such as #3498db.
  2. Read the RGB. The tool splits the hex into red, green and blue channels locally.
  3. Copy the value. Copy the rgb() value, or reverse the tool to convert RGB to hex.

Frequently asked questions

What is #3498db in RGB?

rgb(52, 152, 219). The pairs 34, 98 and db convert to 52, 152 and 219.

Can it convert RGB back to hex?

Yes. The converter works both ways between hex and RGB.

How does a three-digit hex like #abc work?

Each digit is doubled, so #abc is the same color as #aabbcc.

Related answers