RGB To Hex

Convert RGB and RGBA colours to HEX codes

Convert rgb(255, 128, 0), rgba with transparency, percentages or plain "255, 128, 0" values into HEX codes - with short form, lowercase and the nearest CSS colour name.
Try an example:

Output will appear here...

About RGB To Hex

How it works

  1. Each line is read as red, green and blue values from 0-255 (percentages also work) and an optional alpha (transparency) from 0-1.
  2. Each value is written as two hexadecimal digits: 255 → FF, 128 → 80, 0 → 00.
  3. With transparency, a fourth pair is added (#RRGGBBAA). We also find the closest of the 148 named CSS colours.

What you need

  • One or more RGB colours, one per line: rgb(…), rgba(…), "255 128 0" or a CSS colour name.

Tips

  • #RRGGBBAA (8-digit hex) is supported in all modern browsers.

Runs in your browser. Everything happens in your browser - your code and data are never uploaded.

Frequently asked questions

Why are there 8-digit HEX codes?+

The last two digits store the alpha (opacity): #4F46E580 is the colour #4F46E5 at 50% opacity.