Home/Tools/Developer Tools/RGB to HEX

RGB to HEX Converter

Developer Tools

Also available as:Color ConverterHEX to RGB

HEX

#4f46e5

RGB

rgb(79, 70, 229)

HEX (8-digit, with alpha)#4f46e5
RGBArgba(79, 70, 229, 1)
HSLhsl(243, 75%, 59%)
HSLAhsla(243, 75%, 59%, 1)
HSV / HSBhsv(243, 69%, 90%)
CMYK (approximate)No ICC profile: a naive RGB→CMYK formula, fine for a rough idea, not for print.cmyk(66%, 69%, 0%, 10%)
CSS named colorroyalblue (closest match, not exact)
Tailwind arbitrary valuebg-[#4f46e5]
CSS custom property--color-custom: #4f46e5;
TextContrast on white: 6.29:1WCAG AA
TextContrast on black: 3.34:1WCAG AA large text only

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

What the RGB to HEX does

RGB to HEX converts a color given as red, green and blue values (0–255) into the six-digit hexadecimal code used in CSS, design tools and brand guides. Type rgb(79, 70, 229) or just 79, 70, 229 and copy #4f46e5; alpha values produce an eight-digit code. HSL, HSV, approximate CMYK and contrast ratios are shown too. It is for developers and designers moving colors between tools; it does not handle wide-gamut color spaces.

How to use it

  1. 1Type the RGB value: rgb(79, 70, 229), rgb(79 70 229) or simply 79, 70, 229.
  2. 2Read the hex code in the first card; it updates as you type.
  3. 3Press Copy, or copy the RGBA/8-digit hex if the color has an alpha value.
  4. 4Check the contrast ratios if the color will be used for text.

Options explained

RGB input forms
Commas or spaces between channels, with or without the rgb() wrapper. Percentages (50%) are accepted per channel. An alpha value after a comma or a slash produces an 8-digit hex.
Hex output
Lowercase six-digit code with a leading #, the form CSS, Figma and most design tools expect. Hex is case-insensitive, so #4F46E5 and #4f46e5 are the same color.
Picker
Click the swatch to choose a color visually; the hex and RGB update together.
Other notations
HSL, HSLA, HSV, approximate CMYK, nearest CSS name, Tailwind arbitrary value and a CSS custom property are listed under the main cards, each with Copy.
Contrast
WCAG ratios of this color as text on white and black, with the AA/AAA level reached.

Common problems and limits

Channels outside 0–255 are clamped, not rejected; a typo such as 300 silently becomes 255, so check the swatch.

CMYK is an approximate formula without an ICC profile.

Wide-gamut (Display P3, OKLCH) is not supported; values are sRGB.

Who uses it

  • Front-end developers: Turn the rgb() a color picker gave you into the hex your stylesheet or Tailwind config uses.
  • Designers: Convert RGB values from a photo editor into hex for a brand guide or a Figma style.
  • Ecommerce sellers: Match a product color stated as RGB in a supplier sheet to the hex a theme setting expects.
  • Students: See the base-16 arithmetic behind each pair of digits in a hex code.

Frequently asked

How do I convert RGB to hex?

Write each channel (0–255) as a two-digit hexadecimal number and join them with a leading #. rgb(79, 70, 229) becomes #4F46E5: 79 = 4F, 70 = 46, 229 = E5. Type the value above to do it instantly.

What is the hex code for RGB(255, 255, 255)?

#FFFFFF, which is white. Every channel at its maximum 255 is FF in hex. Black, rgb(0, 0, 0), is #000000.

How do I convert RGB to hexadecimal by hand?

Divide the channel by 16; the quotient is the first digit and the remainder the second, using A–F for 10–15. For 229: 14 remainder 5, so E5. Repeat for the other two channels.

Can RGB with alpha be converted to hex?

Yes. rgba(79, 70, 229, 0.5) becomes the 8-digit code #4f46e580, where the last pair (80) is the alpha 0.5 × 255 rounded. All current browsers support 8-digit hex.

Why does my hex code have lowercase letters?

Hex digits are case-insensitive; #4F46E5 and #4f46e5 are identical. This tool outputs lowercase because most formatters and Tailwind do; use whichever your style guide prefers.

Is RGB to hex conversion lossless?

Yes. Both describe the same 24-bit sRGB color (8 bits per channel), so converting back and forth never changes the color. Converting through HSL can round a channel by one.

Automation: an MCP tool convert_color(value, to) → {hex, rgb, hsl} and an n8n node are planned for this tool.