RGB to HEX converter

Paste any RGB color and get its HEX value instantly, together with every other format: HEX, RGB, HSL, HWB, CMYK and OKLCH. Free, and it runs in your browser.

  • Free
  • No sign-up
  • Runs in your browser
rgb-to-hex

Fill in the values above to see the result.

100% private — the calculation is done in your browser and nothing is sent to any server.

How it works

Enter the color

Type or paste a RGB code, or pick a color with the color picker.

Read the HEX value

Every format updates as you type and shows a live preview of the color.

Copy it

Use the copy button next to the format you need.

How to convert RGB to HEX

To convert RGB to HEX, enter your RGB color in the box above and read the HEX value next to it. For example, rgb(239, 68, 68) is #EF4444. The result updates as you type, and every other format (HEX, RGB, HSL, CMYK and more) is shown at the same time.

What RGB and HEX mean

RGB describes a color as amounts of red, green and blue light, each from 0 to 255. rgb(59, 130, 246) is the same color as #3B82F6. CSS also accepts an opacity value, as in rgba(59, 130, 246, 0.5).

A HEX color is a six-digit hexadecimal code with a # in front: two digits each for red, green and blue, from 00 to FF. In #3B82F6, red is 3B, green is 82 and blue is F6. A three-digit shorthand such as #38F repeats each digit, and eight digits add opacity at the end.

Convert RGB to HEX by hand

Here is the calculation for rgb(239, 68, 68), step by step:

  1. Take each channel: red 239, green 68, blue 68.
  2. Convert each one to hexadecimal with two digits (divide by 16: quotient first, remainder second): 239 = EF, 68 = 44, 68 = 44.
  3. Join them after a # sign: #EF4444.

RGB to HEX table of common colors

RGB to HEX
ColorRGBHEX
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF
Redrgb(255, 0, 0)#FF0000
Limergb(0, 255, 0)#00FF00
Bluergb(0, 0, 255)#0000FF
Yellowrgb(255, 255, 0)#FFFF00
Cyanrgb(0, 255, 255)#00FFFF
Magentargb(255, 0, 255)#FF00FF
Grayrgb(128, 128, 128)#808080
Orangergb(255, 165, 0)#FFA500
Purplergb(128, 0, 128)#800080
Pinkrgb(255, 192, 203)#FFC0CB
Brownrgb(165, 42, 42)#A52A2A
Navyrgb(0, 0, 128)#000080
Tealrgb(0, 128, 128)#008080
Coralrgb(255, 127, 80)#FF7F50

When to use RGB and when HEX

RGB is the model screens use and the one CSS functions such as rgba() build on, which makes it handy when you need transparency or want to compute colors in code. HEX is the most compact way to write a color in CSS and design tools, so it is the code most people copy and share.

Good to know

  • Shorthand HEX codes such as #38F expand to #3388FF, and eight-digit codes carry an opacity value at the end.
  • Values are rounded to whole numbers for display; the converter keeps more precision internally.
  • The color picker lets you pick a color by eye when you do not have its code.
  • Colors displayed on screen depend on your monitor's calibration, so the same code can look slightly different on different devices.

Frequently asked questions

How do I convert RGB to HEX?
Enter the RGB color in the converter at the top of this page and read the HEX value. For rgb(239, 68, 68) the result is #EF4444.
What is RGB?
RGB describes a color as amounts of red, green and blue light, each from 0 to 255. rgb(59, 130, 246) is the same color as #3B82F6. CSS also accepts an opacity value, as in rgba(59, 130, 246, 0.5).
What is HEX?
A HEX color is a six-digit hexadecimal code with a # in front: two digits each for red, green and blue, from 00 to FF. In #3B82F6, red is 3B, green is 82 and blue is F6. A three-digit shorthand such as #38F repeats each digit, and eight digits add opacity at the end.
Can I convert to other formats at the same time?
Yes. The converter shows HEX, RGB, HSL, HWB, CMYK and OKLCH together, and you can copy any of them.
Is the conversion exact?
HEX and RGB carry exactly the same information, so converting between them is exact. HSL and CMYK values are rounded for display.
Is it free and private?
Yes. It is free, needs no sign-up and works in your browser, so the colors you type are never sent to a server.