RGB to HEX
Enter your red, green and blue numbers and get back the matching HEX code in seconds, perfect for the web.
About the RGB to HEX Converter
RGB describes a color with three numbers from 0 to 255 - one each for red, green and blue. This tool packs those numbers into a six-digit HEX code, so rgb(52, 152, 219) becomes #3498db. HEX is the most compact way to write a color in HTML and CSS, and it is what most editors and style guides use.
How to use it
- Enter your red, green and blue values, each from 0 to 255.
- Read the matching six-digit HEX code with its
#prefix. - Paste it straight into your CSS, HTML or design file.
Each channel is converted to a two-digit hexadecimal pair and zero-padded, so a value like 5 becomes 05 rather than a single digit. This is the reverse of HEX to RGB and is useful when a screenshot tool or color picker reports values as plain numbers but your stylesheet wants a HEX literal. Values are clamped to the valid 0-255 range, and everything is computed in your browser without uploading anything.
Frequently asked questions
How do I turn RGB values into a HEX code?
Convert each of the red, green and blue numbers (0-255) to a two-digit hexadecimal value, then join them in that order behind a # sign. For example 52, 152, 219 becomes #3498db.
What happens if I enter a value above 255?
RGB channels only run from 0 to 255, so out-of-range numbers are clamped to that range before the HEX code is produced.
Why does the HEX code always have six digits?
Each channel is padded to two hexadecimal digits, so a small value like 5 is written as 05. That keeps the code a consistent six characters that CSS recognises.
Is my input processed locally?
Yes. The conversion runs in your browser, so the RGB values you type are never sent to a server.