Skip to Content

RGB to HEX Converter: Red, Green, Blue to CSS Color Code

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.

🔽 Color Preview
#f97316
rgb(249, 115, 22)
🔒 Page code runs in your browser
🔄 Conversions in this browser: 0
★★★★★

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

  1. Move a slider or type a whole number from 0 to 255 in the R, G and B boxes.
  2. Check the preview and the HEX code beside it.
  3. 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

  1. Enter or slide the three values.
  2. Check the preview.
  3. 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.

© 2026 Web Tools Pro. Free RGB to HEX Converter.

Support This Project

I'm Abu Omar from Gaza. I'm working toward an independent income through this free digital project. If you find it useful, please consider supporting me through Binance Pay. Your contribution is optional, and you're welcome here whether you donate or not.

Binance Pay QR code for supporting Abu Omar

Scan with the Binance app to support.

Binance UID: 1210053694