RGB to HEX Converter

Turn red, green and blue values into a HEX code.

Color Tools Free, no sign-up Runs in your browser

RGB to HEX Converter tool

Converted values

About the RGB to HEX Converter

RGB to HEX Converter takes three channel values between 0 and 255 and writes them as the six-digit HEX code that stylesheets expect. Each channel becomes two hexadecimal digits, so red 255, green 153, blue 0 becomes #FF9900. The same colour is also shown in HSL, which is the format to use when you want to adjust it afterwards.

You can type the numbers or drag the sliders. Dragging is the faster way to find a colour you cannot name precisely, because the preview updates continuously and you can see the result at a usable size instead of guessing from numbers.

An optional alpha value adds transparency, producing an eight-digit HEX code and an rgba string. Values outside the valid range are clamped rather than silently producing a wrong colour, and a message tells you when that has happened.

How to use the RGB to HEX Converter

  1. Enter the channel valuesType red, green and blue between 0 and 255, or drag the sliders.
  2. Add alpha if you need transparencyThe alpha slider runs from fully transparent to fully opaque.
  3. Read the HEX and HSL resultsBoth update live alongside a preview of the colour.
  4. Copy the codeEach format has its own copy button.

Features

  • Number inputs and sliders for every channel
  • Live preview that updates as you drag
  • HEX, eight-digit HEX with alpha, rgb, rgba and HSL output
  • Values outside 0 to 255 are clamped with a notice
  • Random colour button for exploring
  • Copy any value in one click

Who uses this tool

The rgb to hex converter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Converting RGB values from a design tool into CSS
  • Writing a HEX code for a colour sampled from an image
  • Translating a brand colour spec given in RGB
  • Finding a colour by eye with the sliders
  • Producing an eight-digit HEX for a semi-transparent overlay

Frequently asked questions

Why are RGB channels limited to 255?

Each channel is stored in eight bits, which gives 256 possible levels from 0 to 255. Three channels of eight bits each make the 24-bit colour that standard HEX codes describe.

What happens if I enter a value above 255?

It is clamped to 255 and a message explains the adjustment, so the preview and the HEX code always reflect a real colour rather than an impossible one.

How is the alpha channel written in HEX?

As two extra digits at the end, giving an eight-digit code. An alpha of 0.5 becomes roughly 80 in hexadecimal, so a half-transparent red is about #FF000080.

Do all browsers support eight-digit HEX?

Every current browser does. If you need to support very old versions, use the rgba form instead, which has been supported far longer.

Is RGB the same as the colour my printer produces?

No. Screens mix light using red, green and blue, while printers mix ink using cyan, magenta, yellow and black. A colour that looks vivid on screen may print duller, so print work needs a conversion step.

What does the random colour button do?

It picks a random value for each channel. It is a quick way to explore unexpected combinations when you are stuck on a palette.

If the rgb to hex converter is not quite what you need, these other free tools solve closely related problems.

HEX to RGB Converter

Turn any HEX code into RGB and HSL values, with alpha support.

Color Tools Use tool

Color Picker

Choose any colour and copy it in HEX, RGB or HSL, with tints and shades.

Color Tools Use tool

Image Compressor

Compress and resize JPEG, PNG and WebP images privately in your browser.

Image Tools Use tool

Percentage Calculator

Three calculators: percent of a number, what percent one number is, and change.

Calculators Use tool

JSON Formatter

Pretty-print and validate JSON, with the exact line and column of any error.

Developer Tools Use tool