RGB to HEX
Slide or type red, green and blue values (0โ255) and get the matching HEX code instantly, with a live preview. Free and private โ everything runs in your browser.
How to convert RGB to HEX
- Set your RGB values. Drag the red, green and blue sliders, type exact numbers (0โ255) into the boxes, or paste a complete string like rgb(30, 144, 255).
- Watch the HEX code update. The 6-digit HEX code and the preview swatch change live as you adjust each channel.
- Copy the result. Click Copy HEX for the bare code, or copy a ready-made CSS declaration or rgb() value.
About this tool
HEX codes are the most compact way to write a color on the web: the red, green and blue values (each 0โ255) are written as three two-digit hexadecimal numbers and joined together. rgb(30, 144, 255) becomes #1e90ff because 30 is "1e" in base 16, 144 is "90" and 255 is "ff". This free RGB to HEX converter does the conversion live while you experiment with the sliders, which also makes it a quick way to fine-tune a color channel by channel until it looks right.
Everything runs locally in your browser, so the colors you work with are never sent to a server. It is a handy companion when moving colors from image editors, screen pickers or JavaScript canvas code (which often give you plain RGB numbers) into CSS, HTML or design tokens that expect HEX. For the reverse direction use the HEX to RGB tool, or get HSL, HWB and CMYK too with the full Color Converter.
Frequently asked questions
How is each RGB number turned into hex digits?
Divide the value by 16: the quotient is the first hex digit and the remainder is the second, using aโf for 10โ15. For example 144 รท 16 = 9 remainder 0, so 144 becomes "90"; 255 รท 16 = 15 remainder 15, so 255 becomes "ff".
Why do RGB values go from 0 to 255?
Each channel is stored in one byte, which holds 2โธ = 256 possible values (0 through 255). That gives 256ยณ โ about 16.7 million โ possible colors, which is the standard 24-bit "true color" range used by screens and web browsers.
Should I write HEX codes in uppercase or lowercase?
Both are valid and identical in meaning โ #1E90FF equals #1e90ff. Lowercase is the common convention in modern CSS style guides, so this tool outputs lowercase.
Can I convert an rgba() color with transparency?
Paste the rgba() string and the red, green and blue parts will be converted; the alpha becomes a fourth HEX pair only in 8-digit codes, which you can build with the Color Converter. This page focuses on the standard opaque 6-digit code.