Skip to content
ToolZone

RGB to HEX

Convert RGB color values into their equivalent HEX code, useful when you have RGB values from a design tool but need HEX for your CSS.

Runs in your browser. Nothing you enter or upload leaves your device.

HEX
#2563EB
RGB
rgb(37, 99, 235)
HSL
hsl(221, 83%, 53%)
CMYK
cmyk(84%, 58%, 0%, 8%)

Contrast (WCAG)

Aa
On white: 5.17:1
✓ AA✗ AAA✓ AA large
Aa
On black: 4.06:1
✗ AA✗ AAA✓ AA large

Tints and shades

Color harmonies

Complementary
Analogous
Triadic

Click any swatch to select it.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the RGB to HEX

Type an rgb() value such as rgb(16, 185, 129) and this tool shows its HEX code right away, together with HSL and CMYK values, a preview swatch, and contrast against white and black.

How it works

Each RGB channel is a number from 0 to 255. To write it in HEX, divide it by 16: the whole-number result is the first hex digit and the remainder is the second, using a-f for 10-15. Red 255 becomes ff, green 87 becomes 57, and blue 51 becomes 33, so rgb(255, 87, 51) is #ff5733.

Type an rgb() value and the tool converts each channel to two hexadecimal digits to build the HEX code, then calculates HSL and CMYK from the same three channels. Because the two formats hold exactly the same information, the RGB values you see always match the HEX code shown.

How to use

  1. 1

    Type an rgb() value into the Color field, for example rgb(16, 185, 129).

  2. 2

    Check the preview swatch.

  3. 3

    Read the HEX row.

  4. 4

    Click the copy icon in the HEX row to copy it.

Worked examples

Orange from RGB values

A designer gives you rgb(255, 87, 51).

Input
R 255, G 87, B 51 (entered in the color picker)
Result
#ff5733

255 = ff, 87 = 57, 51 = 33 in base 16.

Tailwind-style blue

Checking that rgb(37, 99, 235) is the expected brand blue.

Input
R 37, G 99, B 235
Result
#2563eb

Black

The simplest case.

Input
R 0, G 0, B 0
Result
#000000
Limitations
Values must be written as rgb(r, g, b) with 0-255 channels; percentages aren't supported. Alpha transparency is ignored.
Assumptions
RGB values are whole numbers from 0 to 255. Colors are in the standard sRGB space used on the web.
Privacy
Everything runs in your browser, and no colors you pick or type are sent or saved.

Frequently asked questions

What range of values does RGB use?+

Each of the red, green, and blue channels ranges from 0 to 255, which maps to 00 through ff in HEX.

Can I convert RGBA values that include transparency?+

Not with this tool. It works with solid colors only. You can add transparency afterward in CSS using rgb() with an alpha value or an eight-digit HEX code.

How do I type RGB numbers?+

Click the color swatch to open your browser's color picker. In browsers that offer it, switch the picker to RGB mode and type the three values; the HEX code updates to match.

Why is my HEX code six digits?+

Each of the three channels needs two hex digits to represent values from 0 to 255, so a full color takes six.

Is RGB to HEX conversion exact?+

Yes. Both formats store the same three 8-bit values, so there is no rounding or loss of color.

Related tools