Skip to content

Free tool · Colors

RGB to HEX Color Code Converter

Paste an rgb() value and read its HEX code, with HSL and HSV beside it.

See the full color picker How it works

This converter is free with no sign-in. The full color picker is free with a Bravely account.

  • HEX, HSL and HSV
  • Alpha support
  • No sign-in

Try
rgb(52, 211, 153) = #34d399

RGB numbers as hex pairs

The channel values you meet most, each as its two digits. The swatch is the gray that number makes on all three channels.

RGB numberHex pairHow it divides
0000 × 16 + 0
150f0 × 16 + 15
16101 × 16 + 0
32202 × 16 + 0
51333 × 16 + 3
64404 × 16 + 0
102666 × 16 + 6
128808 × 16 + 0
153999 × 16 + 9
192c012 × 16 + 0
204cc12 × 16 + 12
255ff15 × 16 + 15

How it works

RGB to HEX in three steps

  1. 1

    Paste an RGB value

    rgb(52, 211, 153), three bare numbers, or a value with alpha.

  2. 2

    Read the HEX

    The code appears as you type, with HSL and HSV.

  3. 3

    Copy it

    One click on a row copies that value.

What you get

Everything included, free

Reads RGB as you write it

Commas or spaces, percentages, a slash before the alpha, or three bare numbers.

Four notations at once

HEX, RGB, HSL and HSV for the same color, each with its own Copy button.

Alpha as a fourth pair

rgba(124, 58, 237, 0.5) reads as the eight-digit code #7c3aed80.

Kept between 0 and 255

Each channel is rounded to a whole number and kept between 0 and 255.

A swatch as you type

The color shows beside the field, so a slipped digit is plain before you copy.

Runs in your browser

The conversion happens on your device, and no color you type is sent anywhere.

Other ways to get a hex code from RGB

You may not need a converter at all.

  • Built in

    Leave it as rgb()

    Cost
    Nothing
    Good for
    A stylesheet: CSS reads rgb() and a hex code as the same color, so the value can stay as it is.
    Downside
    A tool, a form field or a style guide that only takes hex still needs the code.

    W3C CSS Color Module Level 4: the RGB functions

  • Built in

    Work it out by hand

    Cost
    Nothing but a minute
    Good for
    One color, or learning the notation: each of the three numbers becomes two base-16 digits.
    Downside
    Slow for a list of colors, and a number under 16 needs its leading zero.

    W3C CSS Color Module Level 4: hex notation

  • Built in

    Chrome DevTools

    Cost
    Included with Chrome
    Good for
    A color already in a page's styles: hold Shift and click the preview square beside it to choose another notation.
    Downside
    It converts a color on a page you have open, so a value from anywhere else has to be typed into a style first.

    Chrome DevTools: the Color Picker

  • Ours

    Color Picker

    Cost
    Free with a Bravely account
    Good for
    A color you will keep working with: its harmony schemes, a palette of up to 24, and a file for your code.
    Downside
    It needs a Bravely account, and the converter on this page doesn't pass its color over: paste it in.

What it doesn’t do

  • It converts one color at a time. There is no list or file input.
  • It doesn't read hsv(), hwb(), lab() or oklch() values.
  • HSL, HSV and alpha are rounded, so converting one of them back can land one step from the color you started with.
  • It doesn't keep or export colors: that is the full color picker's job.

Good to know

How the math works

Divide by 16: the whole part is the first digit, the remainder the second.

Read more

Red, green and blue are each a whole number from 0 to 255, and two base-16 digits cover exactly that range. Base 16 counts 0 to 9 and then a to f, so a stands for 10 and f for 15. To write a channel, divide it by 16. The whole part of the answer is the first digit and the remainder is the second.

Take rgb(52, 211, 153). 52 is 3 sixteens and 4 left over: 34. 211 is 13 sixteens and 3 left over, and 13 is written d: d3. 153 is 9 sixteens and 9 left over: 99. Joined after a #, that is #34d399. A second one: rgb(52, 152, 219) is 34, 98 and db, so #3498db. A channel under 16 has no sixteens, so its first digit is 0: rgb(0, 128, 0) is #008000.

What stays exact, and what is rounded

HEX and RGB map one to one. HSL, HSV and alpha are rounded.

Read more

An opaque color converts between RGB and HEX with nothing lost in either direction, because each channel is the same whole number written two ways. Decimals and percentages are legal in CSS, and the converter rounds them to whole channels first: rgb(52.4, 211.6, 153) reads as #34d499. A number above 255 is held at 255.

HSL and HSV are shown as whole numbers, so they are close, not exact. The HSL beside #34d399 is hsl(158, 64%, 52%), and typing that value back gives #36d399, one step of red away. Alpha is kept to two decimal places, so a transparency can shift by one step the same way. When the exact color matters, carry the HEX or the RGB. HSV is the model behind the square in our color picker, and it isn't a CSS notation: a stylesheet takes hsl(), not hsv().

Frequently asked questions

How do I convert RGB to hex?

Paste the value into the box at the top of this page and copy the HEX row. By hand, write each of the three numbers as two base-16 digits and join them after a #: rgb(52, 211, 153) becomes 34, d3 and 99, so the code is #34d399.

What is rgb(255, 255, 255) as a hex code?

#ffffff, which is white: 255 is ff in base 16, three times over. Black, rgb(0, 0, 0), is #000000, and pure red, rgb(255, 0, 0), is #ff0000. The table on this page turns the numbers you meet most into their pairs.

How do I convert RGBA to hex?

Convert red, green and blue as usual, then multiply the alpha by 255, round it, and write it as a fourth pair. rgba(52, 211, 153, 0.5) gives 127.5, which rounds to 128, or 80, so the code is #34d39980. In an eight-digit code, 00 is fully transparent and ff is fully opaque.

Is hex the same as RGB?

In CSS, yes: both write the same sRGB color, and a stylesheet accepts either wherever a color goes. The CSS specification's own example is #00ff00, which it says is the same color as rgb(0 255 0). Hex is shorter, and rgb() shows the three numbers.

Does it read modern rgb()?

Yes. CSS now writes rgb() with spaces and a slash before the alpha, as in rgb(52 211 153 / 50%), and treats rgba() as another name for rgb(). The converter reads both forms, and percentages too.

Do I need an account?

No. Nothing on this page asks for one. The full color picker it links to, where palettes are built and exported, opens after you sign in to a free Bravely account and claim it once.

From the same studio

Bravely Studios builds nine cross-platform desktop utilities: screenshots, PDF signing, remote desktop and more, with one plan that unlocks all of them. Free tools are how we say hello.