RGB to Hex Converter

The RGB to Hex Converter takes the red, green, and blue values you enter in RGB Input (R, G, B) and combines them into a hex color code. Click Convert and your six-digit code appears in Hex Output, ready to paste straight into your CSS. The binary to text converter reads each value in your binary input as a character code point and turns it back into readable text instantly.

Visual Guide: rgb to hex Color Comparison Table

How the rgb to hex Conversion Works

The rgb to hex method translates an RGB shade, input as values for red, green, and blue components ranging from 0 to 255, into a 6-digit hex color code (#RRGGBB). Each part (r, g, b) is individually turned into a two-digit hex number, then concatenated in order. The formula for this conversion is:

Formula:
Convert each channel:
$$R_{hex} = \text{toHex}(R)$$
$$G_{hex} = \text{toHex}(G)$$
$$B_{hex} = \text{toHex}(B)$$
Concatenate as: #RRGGBB

The function toHex(x) converts the numeric amount x to a two-digit hexadecimal string, padding with a leading zero if necessary. Type a Tailwind class name into the tailwind to hex converter to get its exact hex color code in return.

For example, rgb(57,77,254) translates as:

  • Red: 57 (39 in hex)
  • Green: 77 (4D in hex)
  • Blue: 254 (FE in hex)

Hex result: #394DFE

This process lets you convert any rgb value and get the corresponding 6-digit hex for use in markup, stylesheets, web authoring, and graphic layouts.

Sample rgb to hex Conversions and Color Codes Table

Below is a quick reference rgb to hex color table showing some common shade notations with their rgb, hex, and a live color swatch for easy comparison. Use this chart to explore some hues and see how rgb maps directly to hex strings like #ff0000 or #394dfe. To explore individual values for red code, green code, and blue code, enter a color code below to see the conversion.

Color Name(R,G,B)Hex CodeColor Swatch
Black(0, 0, 0)#000000
White(255, 255, 255)#ffffff
Red(255, 0, 0)#ff0000
Lime(0, 255, 0)#00ff00
Blue(0, 0, 255)#0000ff
Yellow(255, 255, 0)#ffff00
Cyan(0, 255, 255)#00ffff
Magenta(255, 0, 255)#ff00ff
Silver(192, 192, 192)#c0c0c0
Gray(128, 128, 128)#808080
Maroon(128, 0, 0)#800000
Olive(128, 128, 0)#808000
Green(0, 128, 0)#008000
Purple(128, 0, 128)#800080
Teal(0, 128, 128)#008080
Navy(0, 0, 128)#000080

This comparison demonstrates the identical appearance in both the rgb (numeric) and hex (hexadecimal) notation. Adjust the bands to convert each component to hex and achieve the desired shade for your web design or markup.

Worked Examples: Convert RGB to Hexadecimal Code

  1. Convert pure red color (255, 0, 0) to hex color code
    • Known values: R = 255, G = 0, B = 0
    • Apply formula: #RRGGBB
    • Convert each part:
      R: 255 → FF hex
      G: 0 → 00 hex
      B: 0 → 00 hex
    • Result: #ff0000
  2. Convert a web-safe blue shade (0, 85, 255) to hex
    • Known values: R = 0, G = 85, B = 255
    • Apply formula: #RRGGBB
    • Convert each part:
      R: 0 → 00 hex
      G: 85 → 55 hex
      B: 255 → ff hex
    • Result: #0055ff
  3. Convert a gray tone (128, 128, 128) to hex
    • Known values: R = 128, G = 128, B = 128
    • Apply formula: #RRGGBB
    • Convert each part:
      R: 128 → 80 hex
      G: 128 → 80 hex
      B: 128 → 80 hex
    • Result: #808080

These examples show how to convert the red, green and blue channel code values from numbers to hex for any given color. Remember, the outputs are always in full six-digit hex for universal compatibility. Try to enter a color code and see how its red code, green code, and blue code convert to a single hex.

Explore More: rgb to hex converter Tools & Related Conversions

Other Useful Color Code Converters for CSS and HTML

Chances are, you'll want to move tints between a variety of formats for web design, image translation, and layout software. Here are some powerful converters you should see also: Use the hex to benjamin moore converter to get a nearest-match paint name suggestion for a hex color, keeping in mind it isn't verified brand data.

  • hex to rgb converter – Easily convert a hex to rgb format for use in photo manipulation or code.
  • rgba to hex converter – Coverts rgba (which includes a transparency channel) to hex.
  • hex to oklch converter – Transform your hex string into a modern OKLCH value often used in styles and modern workflows.
  • RGB to HSL – Convert rgb numbers to the corresponding hsl hue, saturation, and lightness values for more complex styling needs.
  • RGB to HSV – Find the hsv equivalent, helpful for certain style use-cases or stylistic effects.
  • RGB to CMYK – Move from rgb to cmyk specs, often vital for print and publishing.

If you often move palettes between design tools or normalize formats across a codebase, these options provide a smooth transformation process that supports not just hex color code and rgb, but also hsl, hsv, oklch and cmyk and more. Stay consistent no matter where your color journey leads you—whether your stylesheet specifies hex or you're pasting rgb numbers in your html/styles.

Help Improve This Color Converter Tool

How to Use the RGB to Hex Converter

This converter is processed locally—meaning your chromatics you paste never leave your browser. Whether you're working with rgb(57,77,254) for a curious blue or #808080 for gray, you can copy the hex and use that shade instantly across platforms. If you're working with images, visual software, or front-end development, the rgb to hex converter keeps your tints unified, minimizing manual math and maximizing accuracy. Try to enter a color code, and let this tool convert rgb to hex without error.