Hex to RGB Color Converter

  • Tested against the CSS Color 4 examples and 300 codes checked in Python
  • Checked by Wayne Bickerton
  • Sources: W3C
  • Updated November 11, 2026

A hex color code is three pairs of base-16 digits for red, green and blue (RGB), each from 0 to 255: #2563EB is 37, 99, 235. Paste a hex code from a design file or a web page to get its RGB values. Or type the red, green and blue values to get the hex code: the boxes stay in step both ways. Short codes such as #FFF and codes with transparency (alpha) work too.

In RGB
rgb(37, 99, 235) Solid

#2563EB is red 37, green 99 and blue 235.

Red 37
Green 99
Blue 235
Hex
#2563EB
CSS
rgb(37 99 235)

How to convert hex to RGB

A hex colour code is three numbers in base 16, one each for red, green and blue light, from 00 (none) to FF (full, 255). Hex digits run 0–9 then A–F for 10–15, so each pair is first digit × 16 + second digit:

Each pair of hex digits = first digit × 16 + second digit (0 – 255)

Here it is with your numbers:

  1. Red: 25 is 2 × 16 + 5 = 37.
  2. Green: 63 is 6 × 16 + 3 = 99.
  3. Blue: EB is 14 × 16 + 11 = 235.

It means #2563EB is rgb(37, 99, 235) on a scale where 0 is none of that light and 255 is full.

A 3-digit code is a short form with each digit doubled (#36F is #3366FF). An 8-digit code adds a fourth pair for alpha, how see-through the colour is: 00 is invisible and FF is solid.

Source W3C · CSS Color Module Level 4, §5.2 The RGB hexadecimal notations ↗

How to convert RGB to hex

Go the other way: divide each value by 16. The whole number is the first hex digit and the remainder the second (10 – 15 are A – F).

Each channel ÷ 16 = first hex digit, remainder = second hex digit

Here it is with your numbers:

  1. Red: 37 ÷ 16 is 2 remainder 5, so 25.
  2. Green: 99 ÷ 16 is 6 remainder 3, so 63.
  3. Blue: 235 ÷ 16 is 14 remainder 11, so EB.
  4. Put them together after a #: #2563EB.

It means rgb(37, 99, 235) and #2563EB are the same colour.

Basic CSS colours in hex and RGB

NameHexRGB
black#0000000, 0, 0
silver#C0C0C0192, 192, 192
gray#808080128, 128, 128
white#FFFFFF255, 255, 255
maroon#800000128, 0, 0
red#FF0000255, 0, 0
purple#800080128, 0, 128
fuchsia#FF00FF255, 0, 255
green#0080000, 128, 0
lime#00FF000, 255, 0
olive#808000128, 128, 0
yellow#FFFF00255, 255, 0
navy#0000800, 0, 128
blue#0000FF0, 0, 255
teal#0080800, 128, 128
aqua#00FFFF0, 255, 255

Source W3C · CSS Color Module Level 4, §6.1 Named colors ↗

FAQs

How do I convert hex to RGB?

Split the code into three pairs, one each for red, green and blue, and turn each pair from hexadecimal into a number from 0 to 255: the first digit × 16 plus the second. #2563EB is 25, 63 and EB, which is 37, 99 and 235.

Source W3C · CSS Color Module Level 4, §5.2 The RGB hexadecimal notations ↗

Is hex the same as RGB?

Yes, the same colour written two ways. A 6-digit hex code is just the red, green and blue values in base 16: #FF0000 and rgb(255, 0, 0) are both pure red.

What is #0000ff in RGB?

rgb(0, 0, 255): no red, no green and full blue. CSS calls it blue.

Source W3C · CSS Color Module Level 4, §6.1 Named colors ↗

What is the RGB value for #fffff?

#fffff has 5 digits, which isn’t a valid hex colour (it needs 3, 4, 6 or 8). You probably meant #ffffff, which is rgb(255, 255, 255): white.

Source W3C · CSS Color Module Level 4, §5.2 The RGB hexadecimal notations ↗

Sources

Related calculators