RGB to HEX Converter
About this tool
About RGB to HEX Converter
Turn RGB values into a hex colour code for CSS, HTML, design tools or brand guidelines. Paste rgb(91, 61, 245), the newer space-separated rgb(91 61 245), percentages, or just three numbers like 91, 61, 245, and the hex code appears at the top of the results. If your colour has transparency, such as rgba(91, 61, 245, 0.5), you get the 8-digit hex form with the alpha channel included, which all modern browsers support. The other common formats are listed below it, including HSL, OKLCH and CMYK, along with the nearest CSS colour name and contrast against white and black. Sliders let you nudge the hue, lightness or opacity before you copy, and the tints and shades row offers lighter and darker neighbours if you need a hover or border colour. All conversion happens in your browser, so nothing is sent anywhere.
Built and maintained by Abhi JainUpdated
How to Convert RGB to HEX
- 1
Enter the RGB value
Paste rgb() or rgba(), or three numbers separated by commas, into Enter any colour.
- 2
Copy the HEX code
Press the copy icon next to HEX.
RGB to HEX Converter: questions and answers
How do you convert RGB to HEX by hand?
Convert each channel (0–255) to two hexadecimal digits and join them: 91 → 5B, 61 → 3D, 245 → F5, giving #5B3DF5. Values under 16 need a leading zero, so 5 becomes 05.
How do I convert RGBA to HEX?
Multiply the alpha by 255, round it and convert it to two hex digits, then add it to the end: rgba(91, 61, 245, 0.5) → #5B3DF580.
Why is my hex code lowercase or uppercase?
Case doesn't matter: #5b3df5 and #5B3DF5 are identical. Use whichever matches your code style.
What if a value is above 255?
RGB channels run from 0 to 255, so higher values are clamped to 255 and negative values to 0, just as browsers do.
More Color Picker & Converter presets
Related tools
- Color Palette GeneratorColour harmonies, tints and shades and a 50–950 scale, exported as CSS, Tailwind, JSON or PNG.
- Color Contrast CheckerCheck WCAG 2.2 AA and AAA contrast for text and UI, and get the nearest passing colour.
- Color Extractor from ImageExtract the dominant colours from any image and copy them as HEX, RGB or CSS variables.
- CSS Gradient GeneratorLinear, radial and conic CSS gradients with a live preview.