RGB to HEX
Convert an rgb colour to hex, hsl and back.
About this converter
Paste an rgb() or rgba() value and get the hex, the hsl, and whether white or black text will be readable on top of it.
The separators do not matter. Commas, spaces and the modern slash-before-alpha syntax all parse, as do percentage channels — which is useful, because design tools and CSS do not agree on which to emit and pasting between them is most of the reason this page gets opened.
An alpha value below 1 produces the eight-digit hex alongside the six-digit one, so you can use whichever the thing you are pasting into understands.
The contrast figures are WCAG ratios against white and black. 4.5:1 is the pass mark for normal text, 3:1 for large.
Frequently asked questions
How do I write transparency in hex?
Two more digits on the end: #RRGGBBAA, where ff is opaque and 00 invisible. Every current browser supports it. If you need to support something older, use rgba() instead, which has worked everywhere for far longer.
Why does my rgb value round oddly in hex?
It should not — each channel is 0 to 255 and maps exactly to two hex digits. Rounding only appears if you started from percentages, where 50% is 127.5 and has to land on one integer or the other.
Does the slash syntax work?
Yes. rgb(255 99 71 / 0.5) is the modern CSS form and parses here, as do commas, plain spaces, and percentages for both the channels and the alpha.
Does what I paste get sent anywhere?
No. The conversion runs in your browser, on your own machine — that is why the result appears as you type rather than after a wait. Nothing is uploaded, nothing is logged, and closing the tab is the end of it. This matters more here than on most pages: tokens, keys and internal data get pasted into tools like this constantly, and most of them are a form that posts to a server.