RGB to Hex Converter
Convert RGB color values to a HEX code. Accepts rgb() or plain comma-separated values. Free, instant, and private.
Independently verified for accuracy
Calculator by Toolsloft ↗Enter RGB values to convert
This tool converts RGB color values to a HEX code for use in CSS, design files, or code. It reads any input with three numbers, such as rgb(51, 102, 204) or 51, 102, 204, and returns the matching hex value. Paste your RGB and copy the result.
How this is calculated
The three numbers are pulled from the input, each is checked to be in the 0 to 255 range, and each is written as a two-digit base-16 value. Inputs without exactly three numbers, or any component above 255, are rejected.
How to use
- Enter RGB values, for example rgb(51, 102, 204) or 51, 102, 204.
- The hex code appears below as you type.
- Copy the hex value into your CSS or code.
Examples
- 51, 102, 204:
#3366cc - rgb(170, 187, 204):
#aabbcc
FAQ
- What RGB formats are accepted?
- Any input with three numbers works, including rgb(51, 102, 204), 51, 102, 204, and 51 102 204. The surrounding text is ignored.
- What range do the values need to be in?
- Each of red, green, and blue must be a whole number from 0 to 255. A value above 255 is rejected.
- Why is the hex always six digits?
- Each color component is written as two hex digits, so the result is always a six-digit code. Leading zeros are kept, for example 16 becomes 10.