HEX to RGB Converter

red FF 15 x 16 + 15 255
green 00 0 x 16 + 0 0
blue 00 0 x 16 + 0 0

#FF0000

This converter reads a hex code as three colour channels, one byte each. If you want the numeric value of the whole hex number instead, convert that hex value to a decimal number.

Going the other way? Convert RGB channels back to a hex code

How do I convert hex to RGB?

A hex colour code holds three channel bytes: #FF0000 is rgb(255, 0, 0). Split the six digits into three pairs, then read each pair as a number from 00 to FF, which is 0 to 255. The first pair is red, the second green and the third blue, and no pair affects another.

  1. Type or paste the code into the box. The leading # is optional and either case is read.
  2. Split the digits into pairs, left to right: red, then green, then blue.
  3. Read each pair as a number. FF is 255, 80 is 128 and 00 is 0.
  4. Write the three numbers as rgb(R, G, B). The working under the box shows the arithmetic behind each channel.
  5. Copy the result, or swap the direction to pack the three channels back into a code.

Hex Pairs and Channel Values

Every pair of digits stands for one channel value. The table runs the range at a readable step so the pattern in the second digit stays visible, and the short table under it gives the six letter digits their values.

Hex Pairs and Channel Values
Hex pairChannel
000
1016
2032
3048
4064
5080
6096
70112
80128
90144
A0160
B0176
C0192
D0208
E0224
F0240
FF255
The letter digits
DigitValue
A10
B11
C12
D13
E14
F15

Worked Example: #FF0000 to RGB

#FF0000 is three pairs. The working below reads each one as a number, using the same place-value arithmetic the number system pages use, and paints the colour beside it.

red FF 15 x 16 + 15 255
green 00 0 x 16 + 0 0
blue 00 0 x 16 + 0 0

#FF0000

Result: #FF0000 = rgb(255, 0, 0)

The three channels give rgb(255, 0, 0), which is what the box above shows. The seeds below are the values this family works from, so the page that goes the other way starts from the same colour.

  • #FF0000 as RGB channels: rgb(255, 0, 0)
  • #FFFFFF as RGB channels: rgb(255, 255, 255)
  • #1A2B3C as RGB channels: rgb(26, 43, 60)
  • #123 expanded to six digits: #112233; as RGB channels: rgb(17, 34, 51)

Check it in reverse

To verify the result by hand, write the channel values back as a hex code and compare it with what you started from.

Worked examples: HEX to RGB

Each example gives the value first, then the working. Select a value to load it in the converter.

What is the RGB value for #ffffff?

#ffffff reads as rgb(255, 255, 255).

Three pairs: FF 255, FF 255, FF 255. Every channel is at the top of its range, which is white.

Load this value in the converter

How do I convert ff0000 to RGB?

ff0000 reads as rgb(255, 0, 0).

Three pairs: FF 255, 00 0, 00 0. The case of the letters carries no meaning, and the # is optional on the way in.

Load this value in the converter

What is #1A2B3C in RGB?

#1A2B3C reads as rgb(26, 43, 60).

Three pairs: 1A 26, 2B 43, 3C 60. Each pair is read on its own, so the letters and the digits never mix across a boundary.

Load this value in the converter

Every example above reverses exactly — pack the same channels back into a hex code.

What a Hex Colour Code Holds

Below are the rules this page follows, in the wording the site uses everywhere. The reference rows are the values the converter enforces: a digit count it does not recognise is refused rather than padded out to one it does.

A hex colour code writes those three channels as three pairs of hexadecimal digits, #RRGGBB: the first pair is red, the second green, the third blue, and each pair runs from 00 to FF, which is 0 to 255.

The three-digit form is shorthand: each digit is doubled to give the six-digit form, so #123 is the same colour as #112233.

A hex colour code may also carry four or eight digits, where the last digit or pair is the alpha channel: 00 is fully transparent and FF fully opaque.

Each channel converts on its own: two hex digits are one channel, so FF is 255, 80 is 128 and 00 is 0. The channels never mix.

iToolHub reads a hex colour code with or without the leading #, in either case, and returns rgb(R, G, B) with each channel from 0 to 255.

An RGB colour is three channel values - red, green and blue - and each one is a whole number from 0 to 255, where 0 is none of that channel and 255 is the most of it.

Three channels of 256 levels each give 256 x 256 x 256 = 16,777,216 colours, which is where the phrase 16.7 million colours comes from.

0b marks binary, 0o octal, 0x hexadecimal; a leading # marks a hex colour. Hexadecimal is not case-sensitive (FF = ff); iToolHub writes hex digits in uppercase.

Reference values
WhatValue
What marks a colour code #
Digit counts read here 3, 4, 6, 8
Hex digits per channel 2
What one channel spans 00 to FF
How the short form expands each digit is doubled
Alpha, fully opaque FF
Alpha, fully transparent 00

What Else Can a Hex Colour Code Hold?

The Three-Digit Short Form

The three-digit form is shorthand: each digit is doubled to give the six-digit form, so #123 is the same colour as #112233. The page expands the short form before it reads the channels, so both spellings give one answer.

The Alpha Digit

A hex colour code may also carry four or eight digits, where the last digit or pair is the alpha channel: 00 is fully transparent and FF fully opaque. The rgb(R, G, B) form carries none, so an alpha value is read and named under the result rather than dropped in silence.

A Number, Not a Colour

A value marked 0x is one hexadecimal number, whatever its digits spell, and this page refuses it by name instead of reading it as three channels. The # is what makes the same digits a colour.

Common Mistakes

Frequently Asked Questions

What does an eight-digit hex colour code mean?

A hex colour code may also carry four or eight digits, where the last digit or pair is the alpha channel: 00 is fully transparent and FF fully opaque. The rgb(R, G, B) form carries no alpha, so it is read and named but not written.

Can RGB be written as percentages instead of 0 to 255?

CSS allows it, and 0% is 0 while 100% is 255. This page reads and writes whole numbers from 0 to 255, because no rounding rule for the values between those two endpoints is stated here, and guessing one would be a wrong answer that looks right.

How do you convert hex to RGB in JavaScript or Python?

Strip the #, take the pairs, and read each pair as base 16: parseInt(pair, 16) in JavaScript, int(pair, 16) in Python. That is the same step the working under each result shows, one channel at a time.

Can a hex colour code have three digits?

Yes. The three-digit form is shorthand: each digit is doubled to give the six-digit form, so #123 is the same colour as #112233.

Yes. The same value converts straight back in the RGB to HEX direction.

The rest of the family sits on the colour converter index.