π¨ Hex to RGB and HSL Converter
Enter a 3- or 6-digit hex color, or set red, green and blue from 0 to 255. The tool shows both notations and a small preview swatch.
What this tool does
The hex to RGB converter translates between hexadecimal colour codes and red, green and blue values. Enter a three- or six-digit hex code such as #3B82F6 and the tool fills in the RGB channels; move the channel values and it produces the matching hex code. A live swatch shows the resulting colour.
A six-digit hex code stores three bytes in order: two digits for red, two for green and two for blue. Each pair ranges from 00 to FF, which is 0 to 255 in decimal. Three-digit shorthand works by doubling each digit, so #f00 is the same as #ff0000, a pure red. The tool also reports the colour in HSL, which is often easier for adjusting lightness and saturation.
The converter is useful for design work, CSS, data visualisation and anywhere a colour arrives in one notation but an API or library expects the other. It does not handle alpha transparency, so eight-digit hex codes and rgba() values are outside its scope.
When to use it
- Convert a designer's hex value into RGB channels.
- Turn RGB values from an image editor into a CSS hex code.
- Check what a three-digit hex shorthand expands to.
- Get an HSL view of a brand colour for a palette.
- Verify a colour value copied from a screenshot or spec.
How it works
- A leading # is optional. Three-digit hex expands by repeating each digit.
- RGB values are clamped to 0β255 and written as a six-digit hex code.
- HSL is calculated from the RGB channels so you can copy either format.
Worked example
Enter #3B82F6. The red channel is 3B in hex, which is 59 in decimal; green is 82, or 130; blue is F6, or 246. The tool reports #3B82F6 and rgb(59, 130, 246) and shows a blue swatch. In the other direction, set red to 255, green to 0 and blue to 0, and the hex field becomes #FF0000. Entering the shorthand #f00 expands to #FF0000 before conversion.
- #fff expands to #FFFFFF, rgb(255, 255, 255).
- #3B82F6 is the common Tailwind blue and converts to rgb(59, 130, 246).
- Red 0, green 128, blue 0 becomes #008000.
Accuracy and limitations
- Only solid colours are supported. Alpha channels, eight-digit hex codes and rgba() strings are not handled.
- Channel values outside 0β255 are clamped, and non-numeric input is treated as zero rather than rejected.
- The hex field accepts three or six hexadecimal digits; named CSS colours and other notations such as hsl() must be converted first.
- Colour perception is not uniform in RGB or HSL, so matching a colour visually may still require adjustment.
Privacy and data handling
The conversion runs locally in your browser. No colour values are uploaded or stored.
Frequently asked questions
Are 8-digit hex colors supported?
No. This tool handles opaque 3- and 6-digit hex only. Alpha channels are ignored rather than guessed.
Does the preview upload the color?
No. The swatch is drawn from the calculated RGB value in the browser.
What does #f00 mean?
It is shorthand for #ff0000: each digit is doubled, giving full red, no green and no blue.
Why does the tool show HSL as well?
HSL describes hue, saturation and lightness, which is convenient for creating lighter, darker or less saturated variants of the same colour.
Can I convert a colour with transparency?
Not here. An eight-digit hex code includes an alpha byte, and this tool expects exactly three or six digits.
Related tools
More Color tools βBackground Remover
Remove the background from a photo and save a transparent PNG β free, private, no sign-up.
QR Code Generator
Make QR codes for links, Wi-Fi, UPI, WhatsApp and more β free PNG and SVG downloads.
Passport Photo Maker
Crop passport, visa and exam-form photos to size, limit the file size in KB and print a copy sheet β free.
Image Compressor
Make JPG, PNG and WebP images smaller with a live quality slider β free and private.