HEX to RGB converter
Paste a hex colour, get rgb(), HSL and OKLCH with a live swatch.
| HEX | #2e8b57 | |
| RGB | rgb(46, 139, 87) | |
| HSL | hsl(146, 50%, 36%) | |
| OKLCH | oklch(56.9% 0.119 154.9) |
Convert HEX color codes to RGB
Paste a hex colour and get its rgb() value, plus HSL and OKLCH, next to a live swatch so you can see you have the right colour. Three-digit shorthand such as #fa3 is expanded automatically, and the # is optional.
How a hex colour encodes red, green and blue
A six-digit hex colour is three bytes in a row: two digits each for red, green and blue, from 00 (none) to ff (full). Convert each pair from base 16:
#2E8B57 → 2E = 46, 8B = 139, 57 = 87 → rgb(46, 139, 87).
RGB is handy when you need to set opacity (rgb(46 139 87 / 50%)) or work with colour values in code. If you are choosing colours for text, check the pair in the contrast checker as well.
Other conversions with this tool
How to convert HEX to RGB
- 1
Paste a hex code like #2e8b57 or #fff.
- 2
Read the rgb() value next to the swatch.
- 3
Copy whichever format you need.
HEX to RGB — frequently asked questions
How do you convert HEX to RGB by hand?
Split the six digits into three pairs and convert each from base 16. #2E8B57 → 2E, 8B, 57 → 46, 139, 87 → rgb(46, 139, 87).
What about 3-digit hex like #fff?
Each digit is doubled: #fa3 means #ffaa33. The converter expands it automatically.
Can I paste a hex code without the #?
Yes. 2e8b57 and #2e8b57 are read the same way.