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
| Colour | Hex | RGB | HSL | |
|---|---|---|---|---|
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | |
| White | #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | |
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | |
| Lime | #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) | |
| Blue | #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) | |
| Yellow | #FFFF00 | rgb(255, 255, 0) | hsl(60, 100%, 50%) | |
| Cyan / Aqua | #00FFFF | rgb(0, 255, 255) | hsl(180, 100%, 50%) | |
| Magenta / Fuchsia | #FF00FF | rgb(255, 0, 255) | hsl(300, 100%, 50%) | |
| Silver | #C0C0C0 | rgb(192, 192, 192) | hsl(0, 0%, 75%) | |
| Gray | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | |
| Maroon | #800000 | rgb(128, 0, 0) | hsl(0, 100%, 25%) | |
| Olive | #808000 | rgb(128, 128, 0) | hsl(60, 100%, 25%) | |
| Green | #008000 | rgb(0, 128, 0) | hsl(120, 100%, 25%) | |
| Purple | #800080 | rgb(128, 0, 128) | hsl(300, 100%, 25%) | |
| Teal | #008080 | rgb(0, 128, 128) | hsl(180, 100%, 25%) | |
| Navy | #000080 | rgb(0, 0, 128) | hsl(240, 100%, 25%) |
Worked examples
| Hex | How it breaks down | Result |
|---|---|---|
| #FF5733 | FF = 255, 57 = 87, 33 = 51 | rgb(255, 87, 51) |
| #8B5CF6 | 8B = 139, 5C = 92, F6 = 246 | rgb(139, 92, 246) |
| #F90 | Expands to #FF9900: FF = 255, 99 = 153, 00 = 0 | rgb(255, 153, 0) |
| #6366F1 | 63 = 99, 66 = 102, F1 = 241 | rgb(99, 102, 241) |
| #3B82F6 | 3B = 59, 82 = 130, F6 = 246 | rgb(59, 130, 246) |
| #4263EB | 42 = 66, 63 = 99, EB = 235 | rgb(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
| Detail | Value |
|---|---|
| Input | Hex #RRGGBB, or the #RGB shorthand — plus #RGBA and #RRGGBBAA with alpha |
| Output | Red, green and blue (0–255), the CSS rgb() string, HSL, HSV and decimal RGB |
| Conversion | Exact — each hex pair is one base-16 number; nothing is rounded |
| Channels | 8-bit each, 0 to 255 (00 to FF) |
| Shorthand | Expanded automatically — #F90 becomes #FF9900 |
| Hash | Optional — FF5733 works the same as #FF5733 |
| Alpha | Eight-digit codes end in the alpha pair; #3B82F680 is about 50% opaque |
| Where it runs | In 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?
What does the shorthand #fff mean?
Can I enter a hex code without the # sign?
How do I use the RGB values in CSS?
Why does my hex code show an error?
Can I convert a hex code with transparency?
Is the conversion exact, or does it round?
What is the biggest value a channel can have?
Does letter case matter in a hex code?
Is my colour uploaded anywhere?
What colour space does the converter use?
What is decimal RGB?
Related tools
Image Compressor
JPG to PNG Converter
PNG to JPG Converter
Unit Converter
Currency Converter
Time Zone Converter
💬 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.