RGB to HEX
Paste a colour written rgb(99, 102, 241), or the three numbers alone, and its hex code is there to copy: #6366f1. A colour with an alpha, such as rgba(99, 102, 241, 0.5), gives the eight-digit form, #6366f180. The colour also shows as HSL, OKLCH and the rest, with tints, shades and its contrast against a background.
What it does
- Old and new CSS syntax both read: rgb(99, 102, 241), rgb(99 102 241) and rgb(99 102 241 / 50%).
- Percentages work too: rgb(40%, 40%, 95%) is #6666f2.
- A value past 255 or below 0 is held to the range, so rgb(300, -5, 0) is #ff0000.
- A fraction such as 99.5 is rounded to the nearest whole step, here 100, which is hex 64.
- The hex is in lower case until you press AB beside it for capitals.
- On a phone, the main button copies the hex straight away.
How to use it
- Paste the rgb() value, or type the three numbers.
- Copy the HEX line.
- Check the contrast against your background if the colour is for text.
What it does not do
- Three-digit shorthand: #6666ff is written out in full rather than as #66f, since every program reads six digits and not every one reads three.
- Pantone and other colour books: they are licensed, so the nearest CSS colour name is given instead.
Questions
How do I convert RGB to hex by hand?
Write each number from 0 to 255 in base 16, padded to two digits, and join them after a #: 99 is 63, 102 is 66 and 241 is f1, so rgb(99, 102, 241) is #6366f1.
What are the last two digits of an eight-digit hex?
The alpha, from 00, fully transparent, to ff, opaque: 0.5 becomes 80. Browsers read #rrggbbaa wherever CSS takes a colour; some design programs and older tools want six digits and a separate opacity.
Is #6366F1 the same as #6366f1?
Yes, hex digits mean the same in either case. Press AB beside the hex if a style guide or a design file writes them in capitals.
Everything here runs in your browser. Nothing you type, paste or open is uploaded, and there is no account and no queue. How that works.
Often used with
- Palette Maker: a whole scale of tints and shades grown from the hex
- QR Code Generator: the hex as a QR code’s colour, its contrast checked
All toolsAbout utilbrewPrivacy