usefmtly

RGB to HEX Color Converter

RGB to HEX Converter — Free RGB to HEX converter. Enter red, green, and blue values (0–255) and get the hex color code instantly. Also outputs HSL and CSS expressions. Real-time preview, one-click copy. No signup required.

Enter R, G, B values (0–255)
HEX
HSL
CSS
R
G
B

Quick swatches

How to convert RGB to HEX

Enter the red, green, and blue values (each between 0 and 255) into the three input fields. The hex code updates in real time — no button press needed. The tool also outputs the HSL equivalent and ready-to-paste CSS expressions.

Use the quick swatches to explore how common colors translate to hex, or type values directly. Decimal values are accepted and rounded automatically.

RGB to HEX conversion formula

Each RGB channel (0–255) is converted independently to a 2-digit hexadecimal number. The three results are concatenated with a # prefix.

ChannelDecimalHex
R (Red)255FF
G (Green)8757
B (Blue)5133

Result: rgb(255, 87, 51)#FF5733

When to use hex vs RGB in CSS

  • Use hex for static color values, design tokens, and brand colors — it is more compact and universally supported.
  • Use rgb() when you need transparency via rgba(), or when computing colors programmatically.
  • Use hsl() when you want to create tints and shades by adjusting lightness — more intuitive than modifying hex digits.

Frequently Asked Questions

How do I convert RGB to hex?

Enter your red, green, and blue values (each between 0 and 255) into the three input fields. The tool converts each channel to two hexadecimal digits and combines them into a 6-character hex code prefixed with #. For example, rgb(255, 87, 51) becomes #FF5733.

What is the formula for RGB to HEX?

Each RGB channel (0–255) is converted to a 2-digit hexadecimal number. Red becomes the first two digits, green the middle two, blue the last two. For example: R=255 → FF, G=87 → 57, B=51 → 33, giving #FF5733. Hex digits go from 0–9 and A–F, where A=10, B=11, … F=15.

What is the difference between rgb-to-hex and hex-to-rgb?

They are the same conversion in opposite directions. Use this tool when you have RGB values and need the hex code — for example, when copying a color from a design tool that shows RGB. Use the Hex to RGB tool when you have a hex code and need the RGB values.

Can I enter decimal values like 128.5?

Yes — decimal values are accepted and rounded to the nearest integer before conversion, since RGB channels must be whole numbers between 0 and 255.

Related Tools