RGB to Hex Converter
Enter red, green and blue — or paste rgb(47, 62, 224) straight from your CSS — and get the hex code, with the alpha channel if there is one, plus HSL and a preview.
Runs entirely in your browser — nothing you enter here is sent to a server.
How RGB becomes a hex code
An RGB color is three numbers from 0 to 255: how much red, green and blue light to mix. A hex code is the same three numbers written in base 16 and glued together after a #. Each channel takes two hexadecimal digits, from 00 (none) to FF (255, full). So rgb(47, 62, 224) is 2F, 3E, E0 — #2F3EE0.
To convert one channel by hand, divide by 16: the quotient is the first digit and the remainder the second, with 10–15 written as A–F. 224 ÷ 16 = 14 remainder 0, which is E0. Nothing is lost or approximated; the two notations describe exactly the same 16.7 million colors.
Six digits
#RRGGBB — the standard form, understood everywhere: CSS, HTML, design tools, most programming libraries.
Three digits
When each pair is a doubled digit, CSS allows a short form: #FFCC00 can be written #FC0.
Eight digits
#RRGGBBAA adds opacity as a fourth pair: 80 is about 50%. Supported by all current browsers.
Alpha first on Android
Android and some other platforms write #AARRGGBB. Mixing the two orders up gives a wrong color, not an error.
Which notation to use
Hex is compact and the usual choice for fixed colors in design tokens and stylesheets. rgb() is easier to read and to compute with, and its modern syntax takes an alpha value directly — rgb(47 62 224 / 50%) — so the older rgba() is no longer needed. hsl() is the one to reach for when you want variations: keep the hue, change the lightness, and you have a hover or a disabled state.
Frequently asked questions
How do I convert RGB to hex?
Convert each of the three values to a two-digit hexadecimal number and join them after a #. For example rgb(255, 99, 71) is FF, 63, 47 — #FF6347.
What is the hex code for RGB 255, 255, 255?
#FFFFFF, which is white. Black, rgb(0, 0, 0), is #000000.
How is transparency written in hex?
As a fourth pair of digits after the color: #RRGGBBAA. 00 is fully transparent and FF fully opaque; 80 is roughly 50%.
Is there any difference between upper and lower case hex?
No. #2F3EE0 and #2f3ee0 are the same color. Pick one style and keep it consistent in your codebase.