Converts between color notations such as HEX, RGB and HSL.
How to use
1
Enter a color code or pick a color.
2
Check the notation you want.
3
Copy it and paste it into CSS or a design tool.
Tips
If you need transparency, use an 8-digit HEX or an rgba() value.
Frequently asked questions
QWhat formats of color code can I enter?
It reads HEX (#6366F1), rgb(), hsl(), hwb(), oklch(), lab(), lch(), color names (tomato) and plain numbers (99, 102, 241). If a value cannot be read, the input border turns red and a notice appears.
QHow do I convert a color with transparency?
When you move the opacity slider below 100%, HEX comes out as 8 digits (#RRGGBBAA), and RGB and HSL come out with an alpha value. Turn on the "legacy syntax" checkbox and it switches to the comma form, like rgba(99, 102, 241, 0.5).
QCan I copy it as SwiftUI or Android code?
Yes. Under "Developer code" below, code is generated for CSS variables, Tailwind, SwiftUI, UIKit, Android (<color>) and Flutter. Click a line to copy it. It also shows 11 lightness steps of the same color and the contrast ratios against white and black backgrounds.
Learn more
1HEX, RGB and HSL are different notations for the same color
#FF5733 writes red 255, green 87 and blue 51 in hexadecimal, so it equals rgb(255, 87, 51). Written in HSL, the same color is hsl(11, 100%, 60%). Because it uses hue (0–360 degrees), saturation and lightness, it is easy to adjust the way people think, such as 'a bit lighter'.
A three-digit shorthand like #F53 means #FF5533, with each digit repeated twice. In the 8-digit form (#RRGGBBAA), the last two digits are the opacity.
2Checking text contrast
Contrast ratio expresses the brightness difference between text color and background color. The Web Content Accessibility Guidelines (WCAG) recommend 4.5:1 or higher for normal text (AA) and 3:1 or higher for large text, and the stricter AAA level is 7:1. Even a pretty color is hard to read for many people if the contrast is low.
This tool calculates the text contrast of the selected color and also creates lightness steps (from light to dark).
3Other color notations and copying code
OKLCH and LAB are notations built to be close to how the human eye perceives lightness, and CMYK is based on the inks used in printing. A CMYK value converted from screen RGB is a computational approximation and differs from real print colors, so for printed matter follow the printer's color profile guidance.
You can copy SwiftUI, Android, Flutter and Tailwind code at once, which is handy when moving the same color across several platforms.
4How do I convert HEX to RGB by hand?
Split the 6-digit HEX into pairs and convert each hexadecimal pair to decimal, and you get the RGB values.
Take #6366F1: 63 is 6×16+3=99, 66 is 6×16+6=102, and F1 is 15×16+1=241, giving rgb(99, 102, 241). The order is red, green, blue from the front.
If calculating by hand is a hassle, just paste the code into the input box. It reads other formats too and shows the color in the other notations.
5What color formats can I enter?
It reads common formats such as HEX, rgb() and hsl(), as well as hwb(), oklch(), lab() and lch(), color names, and plain numbers.
HEX: 3, 6 and 8 digits all work, such as #6366F1, 6366F1 and #63F.
Color names: CSS color names such as tomato and skyblue
Numbers only: comma-separated RGB values such as 99, 102, 241
If the format cannot be read, a notice says it is not recognized. Check that the parentheses and commas are correct.
6How do I read it when I convert RGB to HSL?
HSL expresses the kind of color (hue), how vivid it is (saturation) and its brightness (lightness) as separate numbers.
#6366F1 is hsl(239, 84%, 67%). 239 is a purple close to blue on the color wheel (0 to 360 degrees), 84% is fairly vivid, and 67% is slightly brighter than the middle.
If you remember that red is around 0 degrees, green around 120 and blue around 240, you can get a rough sense of the color from the numbers alone.
7Which notation is convenient when I only want to change brightness?
Notations that separate brightness, such as HSL or OKLCH, make it easy to adjust brightness alone.
With HEX or RGB, the three values move together, so making a darker version means calculating all three numbers. In HSL you only lower the single lightness number, which makes hover and disabled colors easy to create.
However, HSL lightness differs a little from the brightness the human eye perceives. At the same lightness, yellow looks much brighter than blue, and OKLCH is designed to reduce this difference, so it helps when you want similar perceived brightness across different hues.
8What is OKLCH and why use it?
OKLCH describes a color by lightness (L), chroma (C) and hue (H), and it is designed to be close to the brightness differences the human eye perceives.
Converting #6366F1 gives something like oklch(58.5% 0.204 277.1). Changing only the hue value gives other colors of similar brightness, which is useful when building several theme colors.
Modern browsers support oklch(), but it may not display in older environments. If support is a concern, it is safer to also list a HEX value.
9How do I make a HEX with transparency (alpha)?
Adding two more digits after the HEX makes it transparency: 00 is fully transparent and FF is fully opaque.
The values for commonly used opacities are below. When you move the opacity slider in this tool, the 8-digit HEX and rgba() change together.
100%
Two-digit value
FF
Opacity
50%
Two-digit value
80
90%
Two-digit value
E6
Opacity
40%
Two-digit value
66
80%
Two-digit value
CC
Opacity
30%
Two-digit value
4D
70%
Two-digit value
B3
Opacity
20%
Two-digit value
33
60%
Two-digit value
99
Opacity
10%
Two-digit value
1A
Opacity
Two-digit value
Opacity
Two-digit value
100%
FF
50%
80
90%
E6
40%
66
80%
CC
30%
4D
70%
B3
20%
33
60%
99
10%
1A
10Why is the order of Android color codes different?
On the web, an 8-digit HEX has the transparency at the end, but Android puts it at the front, so copying it as is shifts the color.
For example, #6366F180 on the web must be written #806366F1 in Android XML. This tool also generates the Android format separately in the developer code area.
SwiftUI's Color(red:green:blue:) and UIKit's UIColor take decimals between 0 and 1 instead of 0 to 255. These values are calculated and shown too, so you can copy them as they are.
The web uses RRGGBBAA and Android uses AARRGGBB. This is the most common mistake when moving a transparent color.
11Can I use CMYK values for printing as they are?
They are reference values calculated for the screen, so they may differ from the actual printed result.
RGB and CMYK can express different ranges of colors. Even when converted to the same numbers, the result unavoidably varies with the paper, ink and print settings.
If you are preparing printed material, use these values only as a starting point and verify with a sample or color swatch from the print shop.
12What are common mistakes when entering a color code?
A code usually fails to be recognized because a character is missing or a wrong character is mixed in.
HEX uses only the digits 0 to 9 and the letters A to F. A common mistake is typing the letter O instead of the digit 0.
Case does not matter. #ff6347 and #FF6347 are the same color.
RGB values range from 0 to 255. Values of 256 or more cannot be used.
Add % to HSL saturation and lightness. Write the hue as a plain number in degrees.
It cannot read the value if there are stray spaces or unclosed parentheses.
13How do I find a color name or the nearest name?
When you enter a code, it tells you the closest CSS color name.
If the color matches exactly, the name appears directly; otherwise the most similar name is shown. For example, tomato is #FF6347, the same as rgb(255, 99, 71) and hsl(9, 100%, 64%).
Knowing the name makes it easier to talk about colors in code reviews and with designers. In actual code, however, using the exact HEX instead of the name is more consistent.
14How do I read a 3-digit HEX?
A 3-digit HEX is a shorthand for a 6-digit one, with each character repeated twice.
#F63 is the same as #FF6633, and #0AF is the same as #00AAFF. It can only be used for colors in which each pair of the six digits has identical characters, so a color with different pairs, such as #6366F1, cannot be shortened.
In the 4-digit form, the last character is transparency. #F638 is the same as #FF663388. This tool reads 3, 4, 6 and 8 digits.
15What are the values of common basic colors?
Basic colors have simple values, and memorizing them makes it easier to understand the relationship among HEX, RGB and HSL.
White
HEX
#FFFFFF
RGB
255, 255, 255
HSL
0, 0%, 100%
Black
HEX
#000000
RGB
0, 0, 0
HSL
0, 0%, 0%
Gray
HEX
#808080
RGB
128, 128, 128
HSL
0, 0%, 50%
Red
HEX
#FF0000
RGB
255, 0, 0
HSL
0, 100%, 50%
Yellow
HEX
#FFFF00
RGB
255, 255, 0
HSL
60, 100%, 50%
Green
HEX
#00FF00
RGB
0, 255, 0
HSL
120, 100%, 50%
Blue
HEX
#0000FF
RGB
0, 0, 255
HSL
240, 100%, 50%
Color
HEX
RGB
HSL
White
#FFFFFF
255, 255, 255
0, 0%, 100%
Black
#000000
0, 0, 0
0, 0%, 0%
Gray
#808080
128, 128, 128
0, 0%, 50%
Red
#FF0000
255, 0, 0
0, 100%, 50%
Yellow
#FFFF00
255, 255, 0
60, 100%, 50%
Green
#00FF00
0, 255, 0
120, 100%, 50%
Blue
#0000FF
0, 0, 255
240, 100%, 50%
When R, G and B are equal, the color is neutral. For grays the values are equal, and larger numbers are brighter.
16Are rgb(99 102 241 / 50%) and rgba(99, 102, 241, 0.5) the same?
The two notations are the same color. The first is the modern syntax and the second is the older syntax.
The modern syntax separates values with spaces instead of commas and puts the transparency after a slash. To match older browsers or an existing project, turn on the legacy syntax (commas, rgba) before copying.
The legacy syntax still works in modern browsers, so there is no need to change in a hurry. Standardizing on one in your team's code makes it easier to read.
17How do I make a pastel or darker version?
In HSL, keeping the hue and only raising or lowering the lightness gives lighter and darker colors of the same family.
For example, raising the lightness of hsl(239, 84%, 67%) to 90% gives a pale pastel purple, and lowering it to 30% gives a deep indigo. Lowering the saturation slightly to about 70% gives a calmer feel.
Using this tool's lightness steps, you can see and choose among many steps of the same family right away.
18How do I use the converted code in CSS variables or Tailwind?
Just copy the CSS variable and Tailwind lines from the developer code area and paste them in.
CSS variable: put something like --color-brand: #6366F1; inside :root and use it with var(--color-brand).
Tailwind: putting the HEX in square brackets, like bg-[#6366f1], lets you use it once without any configuration.
For a frequently used color, giving it a name in the Tailwind config is better for maintenance.
iOS and Android code can be copied straight from the developer code area.
19I copied a color code, but it looks different when I paste it.
Most often the # symbol is missing or transparency is being applied, which makes it look different.
HEX in CSS needs a # in front. Some tools require entering it without the #.
In an 8-digit HEX the last two digits are transparency, so the background shows through.
Android XML puts transparency first. Using web code as is shifts the color.
Entering 255-based values into a tool that takes 0 to 1 decimals gives an almost white color.
If your monitor's color settings and the tool's color space differ, the color can look very slightly different.
20What is HWB notation and when is it used?
HWB describes a color by how much white and black are mixed into a hue, which makes it easy to imagine a color from the mixing ratios.
It is intuitive: mixing white into red gives pink, and mixing black gives a deep red. In CSS it is written like hwb(239 39% 5%) and works in modern browsers.
The same color can be made in HEX or HSL, so you do not have to use it. Just choose the notation that is easiest for you to read.
21When do I use the random color and opacity slider?
Random is for quickly browsing new colors when nothing comes to mind, and the opacity slider is for choosing overlay colors.
When you get a color you like, copy the code right away, and if you need a transparent backdrop or shadow color, adjust the opacity to get an 8-digit HEX or rgba value.
The preview also shows how text looks on white and black backgrounds, so you can immediately judge whether it is easy to read.