Upper or lower case doesn't make a difference in CSS. "Rounded" means the whole-number HSL can come back a
few steps off in RGB (out of 255). Tick Exact HSL to get decimals that turn back into exactly this color.
Convert a list
One color per line, in any format. Lines like --brand: #a3e635; work too.
Swatch
Input
HEX
RGB
HSL
HEX to RGB Converter (and RGB to HEX)
What are HEX and RGB colors?
Every color on a screen is a mix of red, green and blue light. RGB writes those three amounts as plain numbers
from 0 to 255. HEX writes the very same three numbers in base 16, squeezed into six characters after a
#.
Take tomato red. As HEX it's #FF6347, as RGB it's rgb(255, 99, 71): full red, some
green, a little blue. Same color, two spellings. Designers and design tools tend to hand you HEX, while RGB is
easier to read and lets you add transparency. This converter takes either one (or HSL, or a name like
tomato) and gives you all the others.
Type or paste it into the big box. It reads #ff6347, ff6347 (no # needed),
#f63, rgb(255, 99, 71), rgb(255 99 71 / 50%), hsl(9 100% 64%),
names like tomato, and even three bare numbers like 255, 99, 71. A whole line copied
from a stylesheet, such as color: #ff6347;, works as well.
The line under the box tells you how it read your color. If something's off, like five hex digits or a
misspelled name, it says what's wrong instead of guessing quietly.
Step 2 Copy the format you need
The results list gives you HEX, HEX with alpha, rgb(), rgba(), the newer space syntax,
hsl(), hsla(), the CSS name (when the color has one) and 0 to 1 values for code that
wants those. Each row has its own Copy button. Use ABC / abc for capital or small letters in HEX, and Short HEX
for #F63 instead of #FF6633.
Step 3 Adjust it if you want
Change the R, G or B box to nudge one channel, or drag Alpha to make the color see-through. The checkerboard
behind the swatch shows how transparent it is. Below that you see how readable the color is as text on white
and on black.
Step 4 Got a lot of colors? Use the list
Paste a list into Convert a list, one color per line, and you get a table with HEX, RGB and HSL for each.
Click a value to copy it, use Copy all for a whole column, or download a CSV for a spreadsheet. This is quick
when you're moving a brand palette from a design file into CSS.
How to convert HEX to RGB by hand
You don't need a tool for this, just a little base-16 math. Hex digits run 0 to 9 like normal, then the letters
take over:
A = 10 B = 11 C = 12 D = 13 E = 14 F = 15
Each pair is "first digit × 16, plus the second digit". Here's #FF6347 worked out:
Pair
Math
Result
FF (red)
15 × 16 + 15
255
63 (green)
6 × 16 + 3
99
47 (blue)
4 × 16 + 7
71
So #FF6347 is rgb(255, 99, 71). Going the other way, divide by 16: 99 ÷ 16 is 6 with 3
left over, which gives 63. For 255 it's 15 with 15 left over, so FF. One thing to watch:
numbers under 16 need a leading zero, so 9 becomes 09, not 9. Leave it out and the whole
code slides out of place.
3-digit and 8-digit HEX codes
When each pair is a double, like FF, 66 and 33, CSS lets you write one digit
per pair. #F63 means #FF6633. Pure white is #FFF, black is #000.
<span class="badge">New</span>
.badge {
color: #fff; /* same as #ffffff */
background: #c00; /* same as #cc0000 */
}
New
Plenty of colors can't be shortened. #FF6347 stays six digits because 63 and
47 aren't doubles. And you can't round your way there: #F64 is #FF6644, which is
a slightly different color.
Eight digits means HEX with alpha. The last pair says how solid the color is, from 00 (invisible) to
FF (solid). #FF634780 is tomato at about half strength. There's a 4-digit short form too:
#F638 is #FF663388. Here are the pairs for some common alpha values:
Alpha
Last two digits
Example
100%
FF
#FF6347FF
90%
E6
#FF6347E6
80%
CC
#FF6347CC
75%
BF
#FF6347BF
50%
80
#FF634780
25%
40
#FF634740
20%
33
#FF634733
10%
1A
#FF63471A
0%
00
#FF634700
Watch out for app code. Android, Flutter and .NET write 8-digit colors as 0xAARRGGBB, with alpha
first. So 0xFFFF6347 is solid tomato, and in CSS it becomes #FF6347FF (or plain
#FF6347). Paste a 0x code into the converter and it reads it that way.
RGBA and transparency
RGBA is RGB plus a fourth number, alpha, from 0 to 1. rgba(0, 0, 0, 0.5) is black at 50%, which is the
classic way to darken whatever sits behind some text so it stays readable:
The blue still shows through the dark strip, because only half of the black is painted. That's the difference
between alpha and picking a darker color: with alpha, the result depends on what's underneath. It's also
why the contrast notes in the converter blend your color with white or black before measuring.
Commas or spaces: old and new RGB syntax
You'll see two ways to write RGB with transparency. Both give the same color:
/* The older comma style */
color: rgba(255, 99, 71, 0.5);
/* The newer space style, same color */
color: rgb(255 99 71 / 50%);
The space version is the newer one from CSS Color Level 4. It puts alpha after a slash, takes it as a percentage
or a number, and works for rgb() and hsl() alike, so you never need the extra "a" in the
name. Current browsers understand both, so use whichever your team already writes. If your code has to run in a
very old browser, stick with commas.
What about HSL?
HSL describes a color the way people talk about it: hue (where it sits on the color wheel, 0 to 360), saturation
(how strong it is) and lightness (how close to black or white). Tomato is hsl(9, 100%, 64%). The nice
part is that you can make a hover color or a pale background by changing just the last number:
.btn { background: hsl(9, 100%, 64%); }
.btn:hover { background: hsl(9, 100%, 54%); } /* a bit darker */
.btn-soft { background: hsl(9, 100%, 94%); } /* very light */
NormalHoverSoft
HSL is usually written with whole numbers, and that rounding means it doesn't always convert back to the exact same
RGB. The converter marks those rows "rounded". Tick Exact HSL if you need a perfect round trip.
Which one should you use in CSS?
HEX for solid colors you copy from a design tool or brand guide. It's short and it's what most
people expect to see in a stylesheet.
RGB with alpha when a color needs to be see-through: overlays, shadows, a faint highlight. You
can do it with 8-digit HEX too, but / 20% is easier to read than 33.
HSL when you're making lighter and darker versions of one color.
Names like tomato or gold are fine for quick tests and demos. There are
only 148 of them, so your exact brand color probably isn't one.
You can mix them freely. A common setup keeps the brand color in a CSS variable and a faded version next to it:
It works in the normal screen color range (sRGB). Colors written as oklch(), lab() or
color(display-p3 …) are handed to your browser to convert, and anything brighter than a normal screen
can show gets pulled into range, so the HEX can look a little duller than the original.
It doesn't do CMYK for print. The HTML Color Picker shows a CMYK starting point,
but check a real print before you trust it.
It can't read CSS variables like var(--brand), because their value lives in your stylesheet, not in
the text you paste. Paste the value itself.
More color tools
HTML Color Picker: pick a color by eye, see its shades and tints, and browse all
148 color names.
Split the HEX code into three pairs and turn each pair from base 16 into a normal number. #FF6347 becomes FF, 63 and 47. FF is 15 × 16 + 15 = 255, 63 is 6 × 16 + 3 = 99, and 47 is 4 × 16 + 7 = 71, so #FF6347 is rgb(255, 99, 71). Or paste the code into the box at the top of this page and copy the result.
How do I convert RGB to HEX?
Divide each number by 16. The whole part is the first hex digit and the remainder is the second (10 is A, 11 is B, up to 15 for F). For 99 that is 6 remainder 3, so 63. Do it for red, green and blue and put them after a #: rgb(255, 99, 71) is #FF6347. The converter on this page does it both ways, so you can paste rgb(255, 99, 71) and copy the HEX.
What is the difference between RGB and RGBA?
RGBA adds a fourth value, alpha, for transparency. rgba(255, 99, 71, 0.5) is tomato red at 50%, so whatever is behind it shows through. Alpha goes from 0 (invisible) to 1 (solid). In current CSS, rgb() accepts alpha too: rgb(255 99 71 / 50%) means the same thing.
How do I add transparency to a HEX color?
Add two more hex digits at the end for alpha. FF is solid and 00 is fully see-through, so #FF634780 is tomato at about 50% (80 in hex is 128, and 128 ÷ 255 is 0.502). Some values to remember: CC is 80%, 80 is 50% and 33 is 20%. Move the alpha slider on this page and the 8-digit HEX updates.
What is a 3-digit HEX code like #F63?
A short form for colors where each pair has two of the same digit. #F63 is the same as #FF6633. Not every color has one: #FF6347 can't be shortened because 63 and 47 aren't doubles. Tick Short HEX on this page to get the short form whenever it exists.
Does upper or lower case matter in HEX colors?
No. #FF6347, #ff6347 and #Ff6347 are the same color in HTML and CSS. Pick one style and stick with it so your stylesheet is easier to search. The ABC / abc switch on this page sets which one you copy.
Why does my HSL value turn back into a slightly different RGB?
HSL is usually written with whole numbers, like hsl(9, 100%, 64%), and that rounding can move the color a few steps in RGB (out of 255) when you convert it back. You won't see the difference on screen, but if you need an exact match, tick Exact HSL and you'll get a value with decimals that converts back to the same RGB.
Can I convert a whole list of colors at once?
Yes. Paste them into Convert a list, one per line, in any mix of formats (HEX, rgb(), hsl(), names). Lines from a stylesheet such as --brand: #a3e635; work too. You get a table with HEX, RGB and HSL, can copy one value or a whole column, or download it as a CSV file for a spreadsheet. Up to 1,000 lines are converted at a time.
Is my color data sent anywhere?
No. The conversion runs in your browser, so nothing you type here is uploaded. The last color and your options (case, short HEX, exact HSL) are kept in this browser's local storage so they are still there next time. The list you paste is not saved.