RGB to HEX Converter
Pack red, green and blue numbers into the compact #RRGGBB hex code the web runs on.
Turn a hex color into its red, green and blue numbers and the CSS rgb() string, exactly.
Updated
Your browser is preparing the tool. It runs 100% locally.
Paste a hex color such as #8B5CF6 and this returns its red, green and blue values, 139, 92, 246, plus the CSS string rgb(139, 92, 246). Each hex pair is one 0-255 channel written in base 16, so the conversion is exact. Three-digit shorthand like #F90 is expanded before converting.
Type a hex color and the tool shows its three RGB channels as decimal numbers from 0 to 255, plus the CSS rgb() string you can paste into a stylesheet. It accepts the six-digit form and the three-digit shorthand, with or without the #, and it repaints a swatch and recalculates on every keystroke. It opens on #8B5CF6 as a worked example.
You need decimal RGB when a hex token won't work: a canvas or WebGL call, an image library in Python or JavaScript, a spreadsheet that builds colors from numbers, a game engine, or an rgba() value where you want the channels separate from the opacity.
A hex color is RGB written in base 16. The six digits are three pairs, one each for red, green and blue. The tool strips the #, expands any three-digit shorthand to six digits, then reads each pair as a number from 0 (written 00) to 255 (written FF).
That mapping is exact, so no color science or rounding is involved: #8B5CF6 always comes back as 139, 92, 246. The page recomputes on every keystroke, and feeding the result into the RGB-to-HEX tool returns the original hex.
The tool fetches no color data. Hex notation encodes an sRGB color as three two-digit pairs, each one 8-bit channel in base 16, so the conversion is plain arithmetic done in the page.
#RRGGBB → R = base16(RR), G = base16(GG), B = base16(BB)
(each pair runs 00-FF, which is 0-255 in decimal)#8B5CF6 → 8B = 139, 5C = 92, F6 = 246 → rgb(139, 92, 246)#F90 → expands to #FF9900 → rgb(255, 153, 0)FF is the largest two-digit hex value (255 in decimal) and 00 the smallest (0). Each channel spans the full 0-255 range, which is why the conversion is exact and reversible.
| Input | Hex #RRGGBB or #RGB shorthand |
|---|---|
| Output | R, G, B (0-255) plus CSS rgb() |
| Conversion | Exact, base-16 to decimal |
| Channels | 8-bit, 0-255 each |
| Shorthand | Three-digit hex expanded automatically |
| Hash | Optional; works with or without it |
| Alpha | Eight-digit #RRGGBBAA not parsed |
| Where it runs | In your browser, live |
Hex and RGB are two notations for the same 8-bit sRGB value, so the conversion is exact and reversible with no rounding drift. Run the output back through RGB to HEX and you get the original hex.
It expects a three- or six-digit hex. An eight-digit hex carrying alpha (#RRGGBBAA) or a named color won't parse and shows an 'invalid input' notice. Strip the alpha pair first, or read it separately as opacity.
Values are read as sRGB. A hex copied out of a wide-gamut (Display P3) workflow is converted as plain sRGB numbers, not remapped to that gamut.
Get the raw 0-255 channels these APIs expect, instead of passing a hex string they can't read.
Take the three RGB numbers and add your own alpha to make a semi-transparent rgba() color.
Feed integer RGB into Python, JavaScript or other image-processing code that works in numbers, not hex.
Drive conditional formatting or chart colors that are defined by numeric channels rather than a hex token.
For the reverse, use RGB to HEX. To adjust a color by hue or lightness, convert it to HSL. For an alpha hex, drop the last pair here and treat it as opacity separately.
Because a hex color is RGB written in base 16, you can check any result yourself: run it back through RGB to HEX and you land on the code you started with.
Pack red, green and blue numbers into the compact #RRGGBB hex code the web runs on.
Pick a colour with the swatch or type a hex code, and read it back as HEX, RGB, HSL and CMYK side by side. Your browser does every conversion.
Check whether your text and background colours have enough contrast to read, with a pass or fail at each WCAG accessibility level.
Compress an image to JPEG with a quality slider and watch the file size drop as you drag, in your browser.
Combine several PDFs into one file in the order you choose, without leaving your browser.
Count words, characters, sentences and paragraphs as you type, with reading and speaking time alongside.
Paste or pick your input at the top of the page. The conversion runs on this device and needs no account.