Home › Converters › Hex to RGB Converter
🌈

Hex to RGB Converter

Convert any hex colour code to RGB values in seconds. Enter a hex code like #FF5733 to see the red, green and blue values, the rgb() string and a colour preview.

About this tool

Designers and developers describe colours in two main ways: hex codes like #FF5733 and RGB values like rgb(255, 87, 51). Websites and style sheets use hex codes, while design tools and image editors often show RGB. This free hex to RGB converter translates between the two in seconds. Type in any hex colour code and it shows the red, green and blue values, the ready-to-paste rgb() string, and a preview swatch of the colour itself. There is nothing to install and no signup, and the conversion runs entirely in your browser.

By Azhar Hussain · Last updated: 7 November 2026

How to use

Type or paste a hex colour code into the box — with or without the hash sign, in upper or lower case. The full six-digit form is #FF5733, the three-digit shorthand #fff means #FFFFFF, and eight-digit codes like #FF5733CC add transparency. The result updates as you type: the red, green and blue numbers separately, the rgb() string with a Copy button, the HSL and HSV values, a contrast rating, and a swatch of your colour. Use the colour picker next to the box to choose a shade visually, or switch to RGB to Hex mode and type the three channel values (0 to 255) — or drag the sliders — to get the hex code back. If the code is not valid, the tool says exactly what is wrong so you can fix it.

The math behind it

A hex colour code is three pairs of hexadecimal digits, one pair for red, one for green and one for blue. Each pair is a number in base 16, from 00 to FF, which is 0 to 255 in decimal. So #FF5733 means red FF, which is 255, green 57, which is 87, and blue 33, which is 51. The three-digit shorthand simply doubles each digit: #fff becomes #FFFFFF, which is white, and #f00 becomes #FF0000, which is pure red. To convert by hand, multiply the first digit by 16 and add the second, remembering that A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.

Eight-digit hex adds an alpha pair at the end: #3B82F680 is the same blue at about 50% opacity, because 80 in hex is 128, and 128 divided by 255 is about 0.502. The three channels also pack into one decimal number: (red × 65,536) + (green × 256) + blue, so rgb(59, 91, 253) is 3,890,173, and 256 × 256 × 256 gives 16,777,216 possible colours.

Common named colours

ColourHexRGBHSL
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Lime#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
Yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
Cyan / Aqua#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
Magenta / Fuchsia#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
Silver#C0C0C0rgb(192, 192, 192)hsl(0, 0%, 75%)
Gray#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
Maroon#800000rgb(128, 0, 0)hsl(0, 100%, 25%)
Olive#808000rgb(128, 128, 0)hsl(60, 100%, 25%)
Green#008000rgb(0, 128, 0)hsl(120, 100%, 25%)
Purple#800080rgb(128, 0, 128)hsl(300, 100%, 25%)
Teal#008080rgb(0, 128, 128)hsl(180, 100%, 25%)
Navy#000080rgb(0, 0, 128)hsl(240, 100%, 25%)

Worked examples

HexHow it breaks downResult
#FF5733FF = 255, 57 = 87, 33 = 51rgb(255, 87, 51)
#8B5CF68B = 139, 5C = 92, F6 = 246rgb(139, 92, 246)
#F90Expands to #FF9900: FF = 255, 99 = 153, 00 = 0rgb(255, 153, 0)
#6366F163 = 99, 66 = 102, F1 = 241rgb(99, 102, 241)
#3B82F63B = 59, 82 = 130, F6 = 246rgb(59, 130, 246)
#4263EB42 = 66, 63 = 99, EB = 235rgb(66, 99, 235), hsl(228, 81%, 59%)

When to use which format

Use HEX for static colour definitions in a style sheet — it is short, exact and what most designers hand over. Use RGB when you need the channels separately: canvas and WebGL calls, image scripts, spreadsheets and data visualisation, or building an rgba() colour where the channels stay separate from the opacity. Use HSL for design systems and theming: raise the lightness by 8 to 10 points for a hover state, or lower the saturation to mute a colour, without changing its hue. All three formats describe the same 16,777,216 colours (256 × 256 × 256).

Technical details

DetailValue
InputHex #RRGGBB, or the #RGB shorthand — plus #RGBA and #RRGGBBAA with alpha
OutputRed, green and blue (0–255), the CSS rgb() string, HSL, HSV and decimal RGB
ConversionExact — each hex pair is one base-16 number; nothing is rounded
Channels8-bit each, 0 to 255 (00 to FF)
ShorthandExpanded automatically — #F90 becomes #FF9900
HashOptional — FF5733 works the same as #FF5733
AlphaEight-digit codes end in the alpha pair; #3B82F680 is about 50% opaque
Where it runsIn your browser, live as you type — nothing is uploaded

The three numbers are the channel values; the rgb() string is the same three numbers wrapped in the CSS rgb() function. HSL and HSV describe the same colour by hue, saturation and lightness or value, which is why designers reach for them when they want a lighter or darker version of a colour.

Methodology and references

Method: each hex pair is read as a base-16 number (first digit × 16 + second digit), so the conversion is exact and reversible — hex to RGB loses nothing. HSL and HSV are rounded to whole numbers, so a round trip through HSL can shift a channel by one. Colours are read as sRGB, the standard colour space of the web; a hex taken from a wide-gamut Display P3 workflow is converted as plain sRGB, not remapped.

References: MDN — CSS hexadecimal color notation · W3C — CSS Color Module Level 4

Frequently asked questions

What is a hex colour code?
A hex code is a six-digit code that describes a colour as three pairs of hexadecimal digits for red, green and blue. For example, #FF0000 is pure red, #00FF00 is pure green and #000000 is black.
What does the shorthand #fff mean?
The three-digit form doubles each digit, so #fff is the same as #FFFFFF, which is white. In the same way, #f00 means #FF0000 (red) and #0f0 means #00FF00 (green).
Can I enter a hex code without the # sign?
Yes. The converter accepts codes with or without the hash sign, in upper or lower case. FF5733, #FF5733 and #ff5733 all give the same result.
How do I use the RGB values in CSS?
Copy the rgb() string from the result, for example rgb(255, 87, 51), and paste it into your style sheet as a colour value, like color: rgb(255, 87, 51);. It works anywhere a hex code works.
Why does my hex code show an error?
This converter accepts three, four, six or eight hexadecimal digits, using only 0 to 9 and A to F — for example #fff, #f80a, #FF5733 or #FF5733CC. Letters beyond F, spaces inside the code, or a code of one, two, five or seven digits will show an error, and the message says which part to fix.
Can I convert a hex code with transparency?
Yes. Use an eight-digit code like #3B82F680, or the four-digit shorthand #f80a, where the last digits are the alpha channel. 80 in hex is 128, and 128 divided by 255 is about 0.502, so #3B82F680 is the same blue at about 50% opacity, shown as rgba(59, 130, 246, 0.502).
Is the conversion exact, or does it round?
Hex to RGB is exact: every hex pair maps to one whole number from 0 to 255, with nothing rounded. HSL and HSV are shown as whole numbers, so converting through HSL and back can shift a channel by one.
What is the biggest value a channel can have?
255, which is FF in hex. Each channel is one byte, so the three channels together give 256 × 256 × 256 = 16,777,216 possible colours.
Does letter case matter in a hex code?
No. #FF5733, #ff5733 and #Ff5733 all give the same result, rgb(255, 87, 51).
Is my colour uploaded anywhere?
No. The conversion runs entirely in your browser, and nothing you type leaves your device.
What colour space does the converter use?
sRGB, the standard colour space of the web. A hex code taken from a wide-gamut Display P3 workflow is converted as plain sRGB, not remapped.
What is decimal RGB?
The three channels packed into one number: (red × 65,536) + (green × 256) + blue. For rgb(59, 91, 253) that is 3,890,173. It is the single 24-bit integer some graphics tools and game engines expect.

Related tools

💬 Comments

Have a question about this page, or an idea to make it better? Share it below — your feedback helps everyone who uses this site.