RGB to HEX Converter: Red, Green, Blue to a CSS Color Code
Set red, green and blue from 0 to 255 with the sliders or number boxes. The HEX code and a color preview update at once. Copy the HEX code for CSS.
What this tool does
Screens make colors from red, green and blue light. RGB writes a color as three numbers from 0 to 255. HEX writes the same color as a # followed by six hexadecimal digits, two for each channel. CSS, design tools and brand guides often use HEX. This tool turns three RGB numbers into the HEX code and shows the color.
Each number is written in base 16 with two digits and a leading zero if needed, then the three pairs are joined: 249, 115, 22 becomes f9, 73, 16, so the code is #f97316. The page code runs in your browser and loads no extra library.
📌 How to use
- Move a slider or type a whole number from 0 to 255 in the R, G and B boxes.
- Check the preview and the HEX code beside it.
- Press Copy HEX, or Reset to go back to orange.
RGB to HEX: inputs, output and examples
This tool converts red, green and blue numbers into a HEX color code. The page code runs in your browser.
Inputs and output
- Input: three whole numbers from 0 to 255, by slider or number box.
- Output: the HEX code (# and six lowercase digits), the same color written as rgb(r, g, b), and a color preview.
Worked examples
rgb(249, 115, 22) is #f97316. rgb(0, 0, 0) is #000000 (black). rgb(255, 255, 255) is #ffffff (white). rgb(51, 102, 153) is #336699. rgb(10, 11, 12) is #0a0b0c: each value below 16 gets a leading zero, so 10 becomes 0a and not a.
How to use it
- Enter or slide the three values.
- Check the preview.
- Press Copy HEX and paste the code into your stylesheet or design tool.
Common mistakes
- Typing a value above 255 or a decimal. The tool shows a message and keeps the last valid color. It does not round for you.
- Leaving a box empty. An empty box is not treated as 0. A message asks for a number.
- Expecting uppercase. The code uses lowercase letters. CSS accepts both.
Limits
The tool converts RGB to HEX only. It does not read HEX back to RGB, and it has no alpha (transparency) channel. Colors may look different on different screens. The counter counts value changes you finish (slider release or number entry) in this browser; moving a slider, Reset and Copy do not add more.
Frequently Asked Questions
How do I convert RGB to HEX by hand?
Write each of red, green and blue in base 16 with two digits, then join them after a #. 255 is ff and 16 is 10.
Why is the HEX code six digits?
Two hexadecimal digits for each of red, green and blue.
Why does 10 become 0a?
Every channel needs two digits, so a single digit gets a leading zero.
What is the largest RGB value?
255, which is ff in HEX.
Does the tool support alpha or transparency?
No. It converts the three RGB channels only.
Can I type decimals like 12.5?
No. Channels are whole numbers from 0 to 255 and the tool shows a message otherwise.
Is the HEX code upper or lower case?
The tool writes lowercase. CSS treats uppercase and lowercase HEX the same.
Is anything uploaded?
The page code does not upload your values. The conversion happens in your browser.