HEX to RGB Converter
Turn a hex color into its red, green and blue numbers and the CSS rgb() string, exactly.
Pack red, green and blue numbers into the compact #RRGGBB hex code the web runs on.
Updated
Your browser is preparing the tool. It runs 100% locally.
Enter red, green and blue as numbers from 0 to 255 and this returns the hex color code, like 139, 92, 246 → #8B5CF6. Each channel becomes a two-digit, zero-padded base-16 pair, joined behind a #. Decimal or out-of-range values are rounded and clamped to 0-255 first, so you always get a valid six-digit hex.
Type red, green and blue values and the tool returns the matching hex code in uppercase, with a live swatch. It reads the numbers out of whatever you paste, so '139, 92, 246', '139 92 246' and even a full rgb(139 92 246) all work. It opens on 139, 92, 246 so there's a result on screen straight away.
Hex is the web's compact color token: one short string you can drop into CSS or HTML, copy into a design tool, or paste into a chat. Photoshop, Figma, OS color pickers and screenshot eyedroppers tend to hand you RGB numbers, and this packs them into the hex that stylesheets use.
The tool pulls the numeric groups out of your input, so the separators you use don't matter. It then clamps each channel to the 0-255 range, rounds it to a whole number, and writes it as a two-digit hexadecimal pair (a single digit gets a leading zero) before joining the three pairs behind a #.
The output is uppercase by convention, though #8B5CF6 and #8b5cf6 are the same color. It updates as you type, and the result is reversible: run it through HEX to RGB and you get your numbers back (as long as they were whole values inside 0-255 to begin with).
No data is fetched. Hex is simply RGB re-encoded in base 16, so the conversion is pure arithmetic: each 0-255 channel maps to exactly one two-digit pair from 00 to FF, as defined for sRGB and CSS hex colors.
R, G, B → #[hex2(R)][hex2(G)][hex2(B)]
(each channel 0-255 becomes a 2-digit pair 00-FF)139, 92, 246 → 8B, 5C, F6 → #8B5CF6255, 102, 0 → FF, 66, 00 → #FF6600Single-digit hex results are zero-padded (0 becomes 00, 9 becomes 09), so every code is exactly six digits. Values above 255 or below 0 are clamped before encoding.
| Input | R, G, B (0-255 each); separators flexible |
|---|---|
| Output | #RRGGBB, uppercase |
| Clamping | Values outside 0-255 are clamped |
| Rounding | Decimals rounded to the nearest integer |
| Padding | Single-digit channels zero-padded |
| Alpha | Not added; six-digit hex only |
| Reversible | Yes, with HEX to RGB (whole-number input) |
| Where it runs | In your browser, live |
For whole numbers in 0-255 the conversion is exact and reversible: send the hex through HEX to RGB and the original channels come back.
Decimals are rounded and out-of-range numbers clamped, so rgb(300, -5, 128.7) becomes #FF0081. The rounding and clamping are deliberate: you always get a valid code, but a messy input won't round-trip perfectly.
It reads numbers only. Percentage notation like rgb(50%, …) isn't supported; convert a percentage to its 0-255 value first (50% is about 128).
The result is a six-digit hex with no alpha. For transparency, append a fourth pair by hand to make an eight-digit #RRGGBBAA color.
Turn the RGB numbers a design app reports into the hex code your CSS or HTML needs.
Convert an RGB value sampled from an image or the screen into a single shareable hex token.
Take RGB produced by a script or spreadsheet and standardise it as web-ready hex.
Shorten a verbose rgb() declaration into the compact hex form for cleaner stylesheets.
Already have a hex and want the numbers? Use HEX to RGB. Need to fine-tune the color? Convert to HSL. For transparency, append an alpha pair to make an eight-digit hex yourself.
Checked against the converter's code: it clamps channels to 0-255 and rounds decimals before encoding, so the output is always a valid six-digit hex and exact for whole-number RGB.
Turn a hex color into its red, green and blue numbers and the CSS rgb() string, exactly.
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.