Skip to main content
toolsxulo

RGB to HEX Converter

Enter R, G, and B values to get the HEX code for the same color, plus HSL and CMYK, with a copy button and a contrast check.

HEX
#F2B705
RGB
rgb(242, 183, 5)
HSL
hsl(45, 96%, 48%)
CMYK
cmyk(0%, 24%, 98%, 5%)

Text contrast (WCAG)

As text on white1.82:1
AaAA failAAA fail
As text on black11.55:1
AaAA passAAA pass

How it works

RGB writes a color as three numbers from 0 to 255. The converter turns each number into two base-16 digits: 242 becomes F2, 183 becomes B7, and 5 becomes 05, so rgb(242, 183, 5) is #F2B705. The same color is also shown in HSL and CMYK, with a contrast check for text on white and on black. A value above 255 or below 0 is clamped to the valid range, because one hex pair only goes up to FF, which is 255.

Read the full guide

How to use it

  1. Enter the red, green, and blue values, each between 0 and 255.
  2. The HEX code, and the HSL and CMYK rows, update at once. Copy the code you need.
  3. Check the contrast to see whether the color is readable as text on white or on black.

Examples

rgb(242, 183, 5)#F2B705 / hsl(45, 96%, 48%) / cmyk(0%, 24.4%, 97.9%, 5.1%)
rgb(28, 30, 34)#1C1E22
rgb(255, 255, 255)#FFFFFF
rgb(255, 0, 0)#FF0000

Frequently asked

How do I convert RGB to HEX?
Convert each channel from base 10 to base 16 and write it as two digits. 242, 183, and 5 become F2, B7, and 05, which is #F2B705. In the converter, enter the three numbers.
Why is HEX shorter than RGB?
Two base-16 characters cover the range 0–255, the same range that can take up to three decimal digits. That is why #F2B705 and rgb(242, 183, 5) are the same color in a shorter form.
What happens with a value above 255?
The tool clamps it to 255, which is the maximum one hex pair can represent. A value below 0 is clamped to 0.
Does the conversion change the color?
No. rgb(242, 183, 5) and #F2B705 are the same color in two formats.

Related tools