Skip to main content
ToolCube – All tools at one place.

RGB to HEX Converter

Enter RGB values to get the HEX color code for CSS, HTML and design tools. RGBA with transparency gives an 8-digit HEX code.

  • RGB to HEX preselected
  • Every format with Copy
  • Contrast checker

Convert a color

Detected: RGB

RGB
HSL

All formats

  • HEX#ff6600
  • RGBrgb(255, 102, 0)
  • HSLhsl(24, 100%, 50%)
  • HSV / HSBhsv(24, 100%, 100%)
  • CMYKcmyk(0%, 60%, 100%, 0%)
  • Nameclosest: orangered
  • CSScolor: #ff6600;

CMYK values are an approximation for screen colors; printed colors depend on the printer profile.

Pick a color from an image

Upload a photo or screenshot (JPG, PNG, WebP, AVIF or iPhone HEIC), then click or tap any point to pick its color. The image stays on your device.

Want to recolor part of an image? Try Change Image Color.

Shades, tints and harmonies

Shades (darker)

  • #e85d00
  • #d15300
  • #b94a00
  • #a24100
  • #8b3800
  • #742e00
  • #5d2500
  • #461c00
  • #2e1300
  • #170900

Tints (lighter)

  • #ff7417
  • #ff822e
  • #ff9046
  • #ff9e5d
  • #ffac74
  • #ffb98b
  • #ffc7a2
  • #ffd5b9
  • #ffe3d1
  • #fff1e8

Harmonies

Complementary – Opposite on the color wheel (180°).

Analogous – Neighbours 30° either side.

Triadic – Three colors 120° apart.

Split-complementary – The two colors next to the complement (150° and 210°).

Tetradic (square) – Four colors 90° apart.

Contrast checker (WCAG)

  • Your color on white

    2.93:1

    Sample of your color as text on #ffffff: contrast 2.93:1.

    • AA normal: Fail
    • AA large: Fail
    • AAA normal: Fail
    • AAA large: Fail
  • Your color on black

    7.15:1

    Sample of your color as text on #000000: contrast 7.15:1.

    • AA normal: Pass
    • AA large: Pass
    • AAA normal: Pass
    • AAA large: Pass
  • Your color on #1e3a8a

    3.52:1

    Sample of your color as text on #1e3a8a: contrast 3.52:1.

    • AA normal: Fail
    • AA large: Pass
    • AAA normal: Fail
    • AAA large: Fail

Guide

How to convert RGB to HEX

  1. Take each RGB value from 0 to 255.
  2. Divide it by 16: the whole part is the first hex digit and the remainder the second (102 = 6 × 16 + 6 → 66).
  3. Use the digits 0–9 and a–f (a = 10 … f = 15), so 255 is ff and 0 is 00.
  4. Join the three pairs after a #: rgb(255, 102, 0) is #ff6600. For alpha, multiply by 255, round, and add a fourth pair.

Why convert RGB to HEX

Many programs and color pickers show colors as RGB numbers, while style guides, CSS files and brand documents usually list HEX codes. Converting gives you a short code that is easy to share, paste into a website builder or keep in a palette. The conversion is exact, so nothing about the color changes.

When the color has transparency, the alpha value from 0 to 1 becomes a fourth pair of hex digits. rgba(255, 102, 0, 0.5) becomes #ff660080. Some older software does not understand 8-digit HEX codes; in that case use the 6-digit code with a separate opacity setting.

Checking your values

Each RGB value must be a whole number between 0 and 255. Values from image editors are sometimes given as percentages, such as rgb(100%, 40%, 0%); this converter accepts those too and turns them into 0–255 values first.

If you have three numbers without the rgb() wrapper, such as 255, 102, 0, you can paste them directly. The converter reads them as red, green and blue. The modern CSS syntax rgb(255 102 0 / 50%) with spaces and a slash works as well.

Common RGB to HEX pairs

A few values are worth knowing by heart: 0 is 00, 128 is 80, 192 is c0 and 255 is ff. So rgb(128, 128, 128) is #808080, a middle grey, and rgb(192, 192, 192) is #c0c0c0, the CSS color silver. When all three pairs repeat a digit, as in #ff6600, you can shorten the code to #f60.

If you work with many colors, keep the HEX codes in one list and convert from there, so every tool uses the same exact values.

RGB to HEX chart of common colors

RGB to HEX values for common colors
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
Silverrgb(192, 192, 192)#c0c0c0
Grayrgb(128, 128, 128)#808080
Maroonrgb(128, 0, 0)#800000
Olivergb(128, 128, 0)#808000
Greenrgb(0, 128, 0)#008000
Purplergb(128, 0, 128)#800080
Tealrgb(0, 128, 128)#008080
Navyrgb(0, 0, 128)#000080
Orangergb(255, 165, 0)#ffa500
Tomatorgb(255, 99, 71)#ff6347

Other colors: use the converter above or the Color Converter.

FAQ

Frequently Asked Questions

Answers to common questions about RGB to HEX on ToolCube.

What is rgb(0, 0, 0) in HEX?

rgb(0, 0, 0) is black, #000000.

Can RGB values go above 255?

No. Each channel is stored in one byte, so the range is 0 to 255. Higher values are not valid colors.

How is alpha written in HEX?

Multiply the alpha (0 to 1) by 255, round it and write it as two hex digits at the end. An alpha of 0.5 becomes 80.