Convert HEX to RGB
Convert a hex colour code to RGB values.
HEX to RGB Converter
Developer tool running locally in browser
What does HEX to RGB Converter do?
Convert a hexadecimal colour code to its red, green and blue components, with support for 3, 4, 6 and 8 digit forms. The 8-digit form carries an alpha channel, which becomes the fourth value in rgba().
How to Use HEX to RGB Converter
- 1Enter the hex codeWith or without the leading hash.
- 2Read the RGB valuesShown as numbers and as a CSS rgb() string.
- 3Copy itOne tap for the CSS form.
Key Features
- 3, 4, 6 and 8 digit hex accepted
- Alpha channel converted to the rgba() fourth value
- Live colour swatch
- Ready-to-paste CSS declaration
- Explains the maths so you can do it by hand
Frequently Asked Questions
How does the conversion work?
Each pair of hex digits is a base-16 number from 00 to FF, which is 0 to 255 in decimal. #FF8800 is red 255, green 136, blue 0.
What does a 3-digit hex code mean?
It is shorthand where each digit is doubled. #F80 expands to #FF8800. It can only express 4,096 of the 16.7 million possible colours, so it is only used when the colour happens to fit.
What is the 8th digit for?
Alpha, or opacity. #4F46E580 has an alpha of 0x80 = 128, which is 50% opacity — equivalent to rgba(79, 70, 229, 0.5). Every current browser supports it.
Which should I use in CSS?
Either — they are identical to the browser. Hex is more compact and more common in design tools; rgb() is easier to manipulate in code because the components are separate numbers.
Input is processed in your browser and never transmitted. That said, treat any web page as untrusted for live production secrets — rotate anything you paste anywhere.
Related Tools
RGB to HEX Converter
Convert RGB values to a hex colour code.
Colour Converter
Convert between HEX, RGB, HSL, HSV and CMYK.
RGB to HSL Converter
Convert RGB values to hue, saturation and lightness.
HSL to RGB Converter
Convert hue, saturation and lightness to RGB and hex.
