Color Converter
Convert any color between HEX, RGB, and HSL formats — in any direction — with a live preview of the color you entered.
Color Converter
HEX accepts 3 or 6 digits, with or without the # sign. RGB values must be 0–255; HSL hue is 0–360 and saturation and lightness are 0–100%.
Conversion formulas (RGB to HSL):
Lightness = (max + min) ÷ 2 | Saturation = (max − min) ÷ (1 − |2 × lightness − 1|) | Hue is computed from which channel is largest, in degrees around the color wheel.
Three Ways to Describe One Color
Every color on a screen can be described in three common formats, and they all mean the same thing. HEX is the shorthand web designers use: #FF0000 is pure red, written as six hexadecimal digits, two for each channel. RGB spells out the same three numbers in decimal: rgb(255, 0, 0). HSL describes the color the way people think about it: a hue on the color wheel, a saturation, and a lightness, so the same red is hsl(0, 100%, 50%). This converter translates between all three formats in any direction, so you can take a color from any source and use it in any tool.
Underneath, all three formats describe the same three numbers: how much red, green, and blue light the screen should mix. HEX packs them into a compact code, RGB lists them plainly, and HSL rotates them into a form that matches human intuition. Converting between them is exact arithmetic, not guesswork: #FF0000 is always rgb(255, 0, 0) and always hsl(0, 100%, 50%), on every device and in every browser.
How to Use This Converter
Choose the format of the color you have, type or paste the value, and the other two formats appear instantly, along with a preview swatch showing the color itself. HEX accepts three or six digits, with or without the hash sign, so #F00, F00, and #FF0000 all mean the same red. RGB accepts three numbers from 0 to 255, separated by commas, with or without the rgb() wrapper. HSL accepts a hue from 0 to 360 and saturation and lightness from 0 to 100 percent, with or without the hsl() wrapper and the percent signs.
If the input is invalid, such as a HEX code with a letter outside the range A to F, or an RGB value above 255, the tool shows an error message instead of a result. That is deliberate: silently guessing at a broken color would be worse than telling you the input needs fixing.
HEX: The Web Designer's Shorthand
A HEX color is six hexadecimal digits, usually written with a leading hash sign. Each pair of digits is one channel: the first two are red, the middle two are green, and the last two are blue. Each pair ranges from 00, meaning none of that channel, to FF, meaning the full amount, which is 255 in decimal. So #FF0000 is full red with no green and no blue, #00FF00 is full green, #0000FF is full blue, #FFFFFF is white with all channels at full, and #000000 is black with all channels at zero.
HEX also has a three-digit shorthand: when each pair of digits is doubled, you can write it once. #F00 means #FF0000, #0F0 means #00FF00, and #FFF means #FFFFFF. Not every color can be shortened this way: #3498DB has no three-digit form, because its pairs are not doubled digits. HEX is the most compact format and the one you will see most often in stylesheets, design tools, and brand guidelines, which is why it is the default input here.
RGB: The Screen's Native Language
RGB describes a color as three numbers from 0 to 255, one for each of the red, green, and blue light channels. It matches how screens actually work: each pixel is a tiny cluster of red, green, and blue lights, and the RGB values set the brightness of each one. Pure red is rgb(255, 0, 0), a mid gray is rgb(128, 128, 128), and the popular flat-design blue #3498DB is rgb(52, 152, 219).
RGB is additive: adding more of every channel makes the color lighter, and all three at full makes white. That is the opposite of paint, where mixing colors makes them darker. This is why a color that looks like a rich blue in RGB can look muddy when printed, because printers use the subtractive CMYK model instead. For anything on a screen, RGB is the ground truth, and HEX is just RGB written in base 16.
HSL: The Format Humans Understand
HSL describes a color with three numbers that match how people talk about color. Hue is an angle from 0 to 360 degrees around the color wheel: 0 is red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, and 300 is magenta. Saturation is a percentage: 100 percent is the most vivid version of the hue, and 0 percent is gray. Lightness is also a percentage: 0 percent is black, 50 percent is the pure hue at full strength, and 100 percent is white.
HSL is the best format for adjusting colors by hand. Want a lighter version of your brand blue? Raise the lightness. Want a softer version? Lower the saturation. Want the complementary color for an accent? Add 180 to the hue. Those operations are awkward in RGB, where lightening a color means raising all three channels by different amounts, but in HSL they are single-number changes. That is why designers often pick a hue first and then tune saturation and lightness to build a palette.
Worked Example: Converting #3498DB
Take the blue #3498DB, a popular flat-design color. Split the hex into pairs: 34, 98, DB. Convert each pair from hexadecimal to decimal: 34 is 52, 98 is 152, and DB is 219. So the RGB form is rgb(52, 152, 219). To find the HSL form, divide each channel by 255: red is 0.204, green is 0.596, and blue is 0.859. The largest value is blue at 0.859 and the smallest is red at 0.204, so the lightness is the average of those two, 0.531, or 53 percent. The difference between the largest and smallest is 0.655, and dividing by the lightness factor gives a saturation of about 70 percent. Because blue is the largest channel, the hue formula gives 204 degrees. The full HSL form is hsl(204, 70%, 53%).
You can check the round trip in the other direction. Starting from hsl(204, 70%, 53%), the chroma, which is the colorfulness, is (1 minus the absolute value of 2 times 0.53 minus 1) times 0.70, which is 0.656. Working through the HSL to RGB formula gives red 52, green 152, and blue 219, which is exactly where we started. Small rounding differences of one unit can appear in either direction, because HSL values are rounded to whole numbers, but a difference of one in a single channel is invisible to the eye.
Tips for Working With Color
Pick colors in HSL, ship them in HEX. Design in HSL because it is the easiest format to reason about, then convert to HEX for your stylesheet. Your code stays compact and your design decisions stay understandable.
Check contrast, not just looks. A color pair that looks fine to you may be unreadable for someone with low vision. The Web Content Accessibility Guidelines ask for a contrast ratio of at least 4.5 to 1 for normal text, which light gray text on a white background almost never meets. Test your combinations with a contrast checker before publishing.
Do not rely on color alone. About 1 in 12 men and 1 in 200 women have some form of color vision deficiency, most commonly confusing red and green. If red means error and green means success in your interface, add an icon or a label as well, so the meaning survives without color.
Keep your palette small. Most good designs use one main color, one accent, and two or three neutrals. A palette built by varying the lightness of a single hue looks more coherent than a rainbow of unrelated colors, and it is easier to keep consistent across a whole site.
Remember that screens differ. The same HEX code looks slightly different on a phone, a laptop, and a calibrated monitor, because every display renders color a little differently. Test important colors on more than one device before finalizing them.
Frequently Asked Questions
What is #FF0000 in RGB and HSL?
#FF0000 is rgb(255, 0, 0) and hsl(0, 100%, 50%). It is pure red: the red channel at full strength, green and blue at zero, hue 0 degrees on the color wheel, fully saturated, at 50% lightness.
How do I convert HEX to RGB by hand?
Split the six hex digits into three pairs and convert each pair from hexadecimal to decimal. For #3498DB: 34 is 52, 98 is 152, and DB is 219, so the RGB form is rgb(52, 152, 219).
What do the numbers in HSL mean?
Hue is an angle from 0 to 360 degrees around the color wheel (0 is red, 120 is green, 240 is blue). Saturation is a percentage from gray (0%) to vivid (100%). Lightness is a percentage from black (0%) through the pure color (50%) to white (100%).
Why does my converted color differ by 1 in one channel?
HSL values are rounded to whole numbers, so converting RGB to HSL and back can shift a channel by 1 out of 255. That difference is invisible to the eye and is normal rounding, not an error.
What is the three-digit HEX shorthand?
When each pair of hex digits is doubled, you can write it once: #F00 means #FF0000, and #FFF means #FFFFFF. Colors like #3498DB cannot be shortened because their digit pairs are not doubled.