RGB to HEX converter
Paste RGB values any way you have them — rgb(255, 99, 71),
255 99 71, percentages, or rgba() with
alpha — and get the hex code as you type. It runs in your browser; nothing is sent anywhere.
Other ways to write it
All formats
Name and Tailwind
Contrast (WCAG)
How RGB becomes hex
Each RGB channel is a number from 0 to 255, and a hex code writes each one as two base-16 digits.
Divide the channel by 16: the quotient is the first digit, the remainder the second,
with 10–15 written A–F. Join red, green and blue, put a # in front, and
that's the hex code. Alpha, if there is one, is 0–1: multiply it by 255, round, and convert that the
same way for two more digits.
rgb(255, 99, 71)
255 ÷ 16 = 15 r 15 → FF
99 ÷ 16 = 6 r 3 → 63
71 ÷ 16 = 4 r 7 → 47
= #FF6347
A channel under 16 still takes two digits: 9 is 09, so
rgb(9, 9, 9) is #090909, not
#999.
The box follows the color in the converter.
rgb(255, 99, 71)
RGB color to hex: common values
The hex values for some well-known RGB colors. Click a row to load it into the converter.
| Color | RGB | HEX |
|---|---|---|
| Tomato | rgb(255, 99, 71) | #FF6347 |
| Coral | rgb(255, 127, 80) | #FF7F50 |
| Orange | rgb(255, 165, 0) | #FFA500 |
| Gold | rgb(255, 215, 0) | #FFD700 |
| Crimson | rgb(220, 20, 60) | #DC143C |
| Hot pink | rgb(255, 105, 180) | #FF69B4 |
| Orchid | rgb(218, 112, 214) | #DA70D6 |
| Indigo | rgb(75, 0, 130) | #4B0082 |
| Royal blue | rgb(65, 105, 225) | #4169E1 |
| Dodger blue | rgb(30, 144, 255) | #1E90FF |
| Sky blue | rgb(135, 206, 235) | #87CEEB |
| Sea green | rgb(46, 139, 87) | #2E8B57 |
| Lime green | rgb(50, 205, 50) | #32CD32 |
| Chocolate | rgb(210, 105, 30) | #D2691E |
| Slate gray | rgb(112, 128, 144) | #708090 |
| Light gray | rgb(211, 211, 211) | #D3D3D3 |
RGB to hex code: questions
How do I convert RGB to a hex code by hand?
Take each channel, divide it by 16, and write the quotient and the remainder as hex digits (10 = A … 15 = F). rgb(65, 105, 225): 65 = 4 × 16 + 1 → 41, 105 = 6 × 16 + 9 → 69, 225 = 14 × 16 + 1 → E1. Joined: #4169E1, royal blue.
How do I convert RGB to hex in JavaScript?
One line does it. The padStart matters: without it, 9 becomes "9" and the code comes out a digit short. Or call the Color API's /v1/convert, below.
"#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("").toUpperCase() How does rgba() become hex?
Alpha goes from 0–1 to 0–255 and becomes two more digits: rgba(255, 99, 71, 0.5) is #FF634780, because 0.5 × 255 = 127.5, rounded to 128, which is 80 in hex. Every current browser reads 8-digit hex in CSS; some older design tools and email clients only take six, so drop the last two there and set the opacity separately.
Why does my hex code have a zero I didn't expect?
Every channel takes exactly two digits, so values under 16 get a leading zero: rgb(0, 128, 9) is #008009. Drop the zeros and #8089 is a different color: a 4-digit hex reads as #88008899, a translucent purple.
What if my values have decimals, percentages, or go over 255?
Decimals are rounded to the nearest whole number (59.6 → 60). Percentages are read as a share of 255, so rgb(100%, 50%, 0%) is #FF8000. Values over 255 aren't valid RGB, so the converter says so instead of guessing a color.
Chrome extension
Need the hex of a color on a web page?
Pick it straight off any page with KD Color and copy the hex — no RGB values to look up first.
Add to ChromeColor API
Do it in code
curl "https://color.koval.tools/v1/convert?value=%23FF6347" One call returns HEX, RGB, HSL, HSV, CMYK, Lab, LCH and OKLCH. No key needed to try it. Convert docs · Pricing
More converters
- HEX to RGB — The reverse: a hex code to rgb() and rgba().
- HEX to CMYK — A hex code to CMYK percentages for print.
- RGB to CMYK — Screen color to print values.
- HSL to HSV — Between the two hue-based models.