How to convert RGB to HEX
- 1To convert RGB to HEX, type your color into the RGB, HEX or HSL box as rgb(255, 87, 51), or as three numbers with commas. It is converted as you type.
- 2Prefer sliders? Drag the Red, Green and Blue sliders, or click the swatch to open your color picker. On Chrome and Edge, the Eyedropper button samples any color on your screen.
- 3Copy the HEX result, lowercase or uppercase, with its copy button. The same card list also gives you HSL and the CSS Color 4 forms.
- 4If your color has transparency, use rgba() or move the Alpha slider and copy the 8-digit hex, which carries the opacity in its last two digits.
How RGB turns into HEX
RGB describes a color with three numbers from 0 to 255 for red, green and blue. HEX writes the very same three numbers in base 16, two digits per channel, with a hash in front. To convert RGB to hex you change each number to base 16 and join the results: rgb(255, 87, 51) gives ff for red, 57 for green and 33 for blue, so the hex code is #ff5733. Because both are exact integer notations, the conversion is lossless and works in both directions.
Each channel must be padded to two digits, which is the step people forget by hand. A value of 5 becomes 05, not 5, so rgb(0, 5, 255) is #0005ff. Values above 255 or below 0 are invalid. This converter checks for that and tells you what it could not read instead of guessing. It accepts commas or spaces, so rgb(255 87 51) and rgb(255, 87, 51) give the same answer.
RGBA adds a fourth value, the alpha, from 0 to 1 or as a percentage. To convert rgba to hex, the alpha is multiplied by 255 and written as two more hex digits at the end, so rgba(255, 87, 51, 0.5) becomes #ff573380. Eight-digit hex is supported by every current browser. The tool also gives the color in HSL, which describes the same color as a hue angle, a saturation and a lightness, a more natural way to make lighter or darker versions.
A WCAG contrast panel below the results shows whether white or black text is readable on your color. Everything runs in your browser, so nothing you type is sent anywhere, and there is no limit on conversions.
When people convert RGB values to hex
CSS and design handoff
Designers often give colors as RGB values; developers usually want a hex code to paste into a stylesheet or a token file.
Using image editor colors
Photoshop, Figma and screenshots report RGB numbers. Turn them into an RGB color to hex value you can use on the web.
Adding opacity
Convert an rgba color to an eight-digit hex for tools that don't accept the rgba() function.
Matching brand colors
Check that a brand RGB value and its hex code describe exactly the same color across print, web and app.
Frequently asked questions
How do I convert RGB to HEX?
+
Type the RGB value into the converter and copy the HEX result. By hand, convert each of the three numbers to base 16 with two digits and put them together after a hash sign.
Where can I get an RGB to hex code online?
+
Right here. Enter the values and the RGB to hex code appears at once, with a copy button. It works as an RGB to hex online tool without any upload or sign-up.
What is rgb(255, 255, 255) in hex?
+
It is #ffffff, white. Every channel is at its maximum, 255, which is ff in base 16. rgb(0, 0, 0) is #000000, black.
Can I convert RGBA to HEX?
+
Yes. Paste the rgba() value and copy the 8-digit hex. The alpha becomes the last two digits, so an alpha of 0.5 is 80.
Is the conversion exact?
+
Yes. RGB and HEX are both whole numbers from 0 to 255, so no rounding is involved when you convert RGB to hex and back.
Can I also get HSL from an RGB color?
+
Yes. The same result list shows RGB to HSL, rounded to one decimal place, plus the modern space-separated CSS syntax.
Is my color sent to a server?
+
No. The conversion runs in your browser and nothing leaves your device.
Related tools
HEX to RGB Color Converter
Convert colors between HEX, RGB and HSL in both directions, including 8-digit hex and alpha. Color picker, RGB sliders, CSS Color 4 syntax and a WCAG contrast check against white and black.
Color Picker from Image
Click any pixel of a photo to get its HEX, RGB and HSL code, with a magnifier and a palette of dominant colors. Works in your browser; nothing is uploaded.
PX to REM Converter
Convert px to rem and rem to px with any root font size. Includes a px-to-rem reference table and a bulk converter that rewrites every px value in a block of CSS.
SVG to PNG
Rasterize SVGs to PNG, JPEG, or WebP at any resolution. Paste source or drop a file, set the export dimensions, and download — ideal for @2x / @3x asset pipelines.