JSONToonPro
Color tool

HEX to RGB Converter

Convert HEX color codes to RGB channel values instantly. Paste any hex code and copy the rgb() output you need, ready for CSS, canvas, or image code. Everything runs 100% client-side in your browser, so your data never leaves your device.

100% client sideInstant resultNo data sent
Click to pick
HEX#2563EB
RGBrgb(37, 99, 235)
HSLhsl(221, 83%, 53%)

RGB channels

Red37
Green99
Blue235

HSL channels

Hue221deg
Saturation83%
Lightness53%

How to Convert HEX to RGB by Hand

A HEX color code looks cryptic at first, but it is just three numbers wearing a disguise. The hash is decoration, and the six characters after it are three pairs of hex digits, one pair each for red, green, and blue. Converting to RGB means turning each pair from base 16 back into an ordinary decimal number between 0 and 255.

The routine is short:

  1. Drop the leading hash and take the six remaining characters.
  2. Split them into three pairs: the first pair is red, the second green, the third blue.
  3. Convert each pair from base 16 to decimal. The left digit counts sixteens, the right digit counts ones.
  4. Write the three results as rgb(red, green, blue).

Worked example: #FF5733

Split into FF, 57, 33 and convert each pair:

FF = (15 x 16) + 15 = 255
57 = (5 x 16) + 7 = 87
33 = (3 x 16) + 3 = 51
Result: rgb(255, 87, 51)

The letters A through F simply stand for 10 through 15, so F is 15 and FF works out to (15 x 16) + 15 = 255, the maximum any channel can reach.

Shorthand Three Digit HEX

You will often see three digit HEX codes like #F53. This is a shorthand that CSS expands by doubling every digit, so #F53 becomes #FF5533. The shorthand only works when both digits of each pair are identical, which is why it can only express 4,096 of the 16 million possible colors. When you convert a three digit code, expand it first, then treat it exactly like a normal six digit code.

#F53 expands to #FF5533
FF = 255, 55 = 85, 33 = 51
Result: rgb(255, 85, 51)

Where You Actually Need RGB

If HEX is so compact, why convert at all? Because plenty of contexts want the raw channel numbers. CSS rgba() is the classic case: to fade a color to fifty percent opacity you need rgba(255, 87, 51, 0.5), and there is no way to add that alpha to a plain HEX color without switching notations. The HTML canvas API expects RGB style strings for its fillStyle and strokeStyle. SVG attributes, WebGL, and most image manipulation code all work in RGB because the individual numbers are what the math operates on. Whenever you need to reason about or animate a single channel, RGB is the format that gives you direct access to it.

Named Color Reference

CSS ships with a set of keyword colors you can write by name instead of a code. They map to exact HEX and RGB values, so the table below is handy when you want to sanity check a conversion or reach for a familiar color without opening a picker.

NameHEXRGB
black#000000rgb(0, 0, 0)
white#FFFFFFrgb(255, 255, 255)
red#FF0000rgb(255, 0, 0)
green#008000rgb(0, 128, 0)
blue#0000FFrgb(0, 0, 255)
yellow#FFFF00rgb(255, 255, 0)
cyan#00FFFFrgb(0, 255, 255)
magenta#FF00FFrgb(255, 0, 255)
silver#C0C0C0rgb(192, 192, 192)
gray#808080rgb(128, 128, 128)
orange#FFA500rgb(255, 165, 0)
purple#800080rgb(128, 0, 128)
teal#008080rgb(0, 128, 128)
navy#000080rgb(0, 0, 128)

Need a different color task? Browse every free developer tool including color converters, encoders, and hashing utilities.

Frequently asked questions

4 answers
Drop the leading hash, split the six characters into three pairs for red, green, and blue, then convert each pair from base 16 to a decimal number between 0 and 255. For example #FF5733 becomes FF, 57, 33, which is rgb(255, 87, 51). Paste any hex code above and the RGB output appears instantly.

More JSON Tools