๐จ Color Converter: HEX to RGB, HSL, HSV and CMYK
By ToolNimba Editorial Team ยท Updated 2026-06-19
Edit any field or use the picker. The others update live.
Paste a color in any common format and read it back in the others. Enter a hex code like #337BFF, an rgb() value, or HSL, and this converter gives you the matching HEX, RGB and HSL at once, plus a live swatch so you can see the color. Everything below explains how the three formats relate, with worked examples you can follow by hand and a chart of common web colors.
What is the Color Converter?
HEX, RGB and HSL are three ways of writing the same thing: a single screen color. RGB is the most direct. It describes a color as three channels (red, green and blue) each running from 0 to 255, which is how displays actually emit light. (255, 0, 0) is full red, (0, 0, 0) is black, and (255, 255, 255) is white. HEX is simply RGB written in base 16 (hexadecimal) so it fits in a compact six-character string. A hex code like #337BFF splits into three pairs: 33, 7B and FF. Each pair is one channel converted to a two-digit hex number, so 33 is red 51, 7B is green 123, and FF is blue 255.
The mapping between a hex pair and a 0 to 255 value is pure base conversion. Hex digits run 0-9 then A-F, where A is 10 and F is 15. The left digit counts sixteens and the right digit counts ones, so the pair 7B is (7 x 16) + 11 = 123. The reverse, going from RGB to HEX, divides each channel by 16: the quotient is the first digit and the remainder is the second. Because two hex digits cover 0 to 255 exactly (16 x 16 = 256 values), every RGB color has one clean six-digit hex code.
HSL takes a different angle and is built for humans rather than hardware. It describes a color by hue, saturation and lightness. Hue is an angle from 0 to 360 degrees around a color wheel (0 is red, 120 is green, 240 is blue). Saturation is how vivid the color is, from 0 percent (gray) to 100 percent (fully colorful). Lightness runs from 0 percent (black) through the pure color at 50 percent to 100 percent (white). Designers reach for HSL because it is intuitive to tweak: to make a button darker on hover you just lower the lightness, and to build a palette you hold the hue and nudge saturation and lightness, which is awkward to do in raw RGB or HEX.
HSV, also called HSB (hue, saturation, brightness), is the cousin of HSL that you meet inside image editors like Photoshop and GIMP. It shares the same hue angle, but its value (or brightness) axis behaves differently from lightness: at 100 percent value the color is the pure, fully saturated hue rather than white, which is why the square swatch in a picker fades to white on one side and to black on the other. HSV and HSL describe the same gamut of colors and convert exactly, but they place those colors on different axes, so the same hue can have very different saturation numbers in each model.
CMYK belongs to a separate world: print rather than screen. Where RGB is additive (you add red, green and blue light to reach white), CMYK is subtractive (you layer cyan, magenta, yellow and a black key ink on white paper, and more ink means a darker result). Each CMYK channel is a percentage from 0 to 100. Converting RGB to CMYK is only an approximation because the two systems cover different ranges of color (gamuts) and real printing depends on the paper, inks and color profile, so treat any RGB to CMYK number as a starting point to refine against a printed proof, not an exact match.
Newer CSS color formats are worth knowing even though most day to day work still uses HEX and RGB. RGBA and 8-digit HEX (#RRGGBBAA) add an alpha channel for transparency, where alpha runs from 0 (fully transparent) to 1, or 00 to FF in hex. HSLA does the same for HSL. Modern browsers also support perceptual spaces such as OKLCH and LAB that keep brightness steadier across hues, which is handy for accessible palettes, but for everyday conversion between HEX, RGB, HSL, HSV and CMYK this converter has you covered.
When to use it
- Converting a brand hex code from a style guide into the rgb() value a design tool or CSS file expects.
- Turning an RGB value picked from a screenshot back into a tidy hex code to paste into HTML or CSS.
- Generating HSL so you can build hover and active states by shifting lightness while keeping the same hue.
- Getting an approximate CMYK breakdown so a screen color can be handed to a printer or used in a print layout.
- Reading the HSV or HSB numbers a photo editor like Photoshop or GIMP shows, so you can match a color across tools.
- Checking that a 3-digit shorthand hex expands to the full 6-digit value you intended.
How to use the Color Converter
- Type or paste a color in any field: HEX (with or without the #), RGB, HSL, HSV or CMYK.
- The other formats update automatically and the swatch shows the resulting color.
- Use the color picker if you want to choose a shade visually instead of typing a code.
- Copy the format you need (for example the rgb() string for CSS or the hex code for a design tool).
Formula & method
Worked examples
Convert the hex code #337BFF to RGB.
- Split into pairs: 33, 7B, FF.
- Red 33 = (3 x 16) + 3 = 51.
- Green 7B = (7 x 16) + 11 = 112 + 11 = 123.
- Blue FF = (15 x 16) + 15 = 240 + 15 = 255.
Result: rgb(51, 123, 255)
Convert rgb(255, 0, 0) to a hex code.
- Red 255: 255 รท 16 = 15 remainder 15, so FF.
- Green 0: 0 รท 16 = 0 remainder 0, so 00.
- Blue 0: 0 รท 16 = 0 remainder 0, so 00.
- Join the pairs and add the #.
Result: #FF0000
Convert the hex code #008000 (web green) to HSL.
- HEX to RGB: 00, 80, 00 gives R = 0, G = 128, B = 0.
- Scale to 0-1: R = 0, G = 0.502, B = 0; max = 0.502, min = 0.
- Lightness L = (0.502 + 0) รท 2 = 0.251, about 25 percent.
- Green is the max channel, so hue = 120 degrees; saturation = 100 percent.
Result: hsl(120, 100%, 25%)
Convert rgb(255, 165, 0) (orange) to CMYK.
- Scale each channel to 0-1: R = 1, G = 0.647, B = 0.
- Key (black) K = 1 - max(R, G, B) = 1 - 1 = 0.
- Cyan C = (1 - R - K) / (1 - K) = (1 - 1) / 1 = 0.
- Magenta M = (1 - 0.647) / 1 = 0.353; Yellow Y = (1 - 0) / 1 = 1.
- Convert to percentages and round.
Result: cmyk(0%, 35%, 100%, 0%)
Common web colors in HEX and RGB
| Color | HEX | RGB |
|---|---|---|
| Black | #000000 | rgb(0, 0, 0) |
| White | #FFFFFF | rgb(255, 255, 255) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #008000 | rgb(0, 128, 0) |
| Lime | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Cyan | #00FFFF | rgb(0, 255, 255) |
| Magenta | #FF00FF | rgb(255, 0, 255) |
| Gray | #808080 | rgb(128, 128, 128) |
| Orange | #FFA500 | rgb(255, 165, 0) |
Same colors across HEX, HSL, HSV and CMYK
| Color | HEX | HSL | HSV | CMYK |
|---|---|---|---|---|
| Red | #FF0000 | hsl(0, 100%, 50%) | hsv(0, 100%, 100%) | cmyk(0, 100, 100, 0) |
| Green | #008000 | hsl(120, 100%, 25%) | hsv(120, 100%, 50%) | cmyk(100, 0, 100, 50) |
| Blue | #0000FF | hsl(240, 100%, 50%) | hsv(240, 100%, 100%) | cmyk(100, 100, 0, 0) |
| Yellow | #FFFF00 | hsl(60, 100%, 50%) | hsv(60, 100%, 100%) | cmyk(0, 0, 100, 0) |
| Orange | #FFA500 | hsl(39, 100%, 50%) | hsv(39, 100%, 100%) | cmyk(0, 35, 100, 0) |
| Gray | #808080 | hsl(0, 0%, 50%) | hsv(0, 0%, 50%) | cmyk(0, 0, 0, 50) |
| White | #FFFFFF | hsl(0, 0%, 100%) | hsv(0, 0%, 100%) | cmyk(0, 0, 0, 0) |
Hex digit to decimal value reference
| Hex digit | Decimal | Hex digit | Decimal |
|---|---|---|---|
| 0 | 0 | 8 | 8 |
| 1 | 1 | 9 | 9 |
| 2 | 2 | A | 10 |
| 3 | 3 | B | 11 |
| 4 | 4 | C | 12 |
| 5 | 5 | D | 13 |
| 6 | 6 | E | 14 |
| 7 | 7 | F | 15 |
Common mistakes to avoid
- Thinking the # is required. In CSS the leading # is part of the hex notation, but for conversion the digits are what matter. 337BFF and #337BFF are the same color, so the # is optional when you enter a value here.
- Mixing 3-digit and 6-digit hex. Shorthand like #3BF expands by doubling each digit to #33BBFF, not by padding with zeros. Treating #3BF as #03B0F0 gives a completely different color.
- RGB channels outside 0 to 255. Each RGB channel only goes from 0 to 255, since that is exactly what two hex digits cover. Values like 300 or negative numbers are invalid and cannot map to a hex pair.
- Confusing HSL percentages with the hue angle. Hue is an angle from 0 to 360 degrees, while saturation and lightness are percentages from 0 to 100. Writing the hue as a percentage breaks the color.
- Treating HSL and HSV as interchangeable. HSL and HSV share a hue but use different saturation and lightness or value axes, so the same color often has different numbers in each. Copying an HSV saturation into an HSL field shifts the color.
- Expecting RGB to CMYK to be exact. Screen RGB and print CMYK cover different color ranges, so any conversion is an approximation. Vivid blues and greens in particular look duller in print. Always confirm against a printed proof and your printer profile.
Glossary
- HEX
- A color written in base 16 as #RRGGBB, where each two-digit pair is one RGB channel from 00 to FF (0 to 255).
- RGB
- Red, green and blue channels, each from 0 to 255, describing how much of each primary light makes up the color.
- HSL
- Hue, saturation and lightness: a human-friendly model that describes a color by its tint, vividness and brightness.
- Hue
- The position of a color on the color wheel, given as an angle from 0 to 360 degrees (0 red, 120 green, 240 blue).
- Saturation
- How vivid or pure a color is, from 0 percent (gray) to 100 percent (fully colorful).
- Lightness
- How light or dark a color is, from 0 percent (black) through the pure color at 50 percent to 100 percent (white).
- HSV / HSB
- Hue, saturation and value (brightness): the model used in many image editors, where 100 percent value is the pure hue rather than white.
- CMYK
- Cyan, magenta, yellow and key (black) ink percentages used in printing. It is subtractive, so more ink gives a darker result.
- Alpha
- The opacity channel in RGBA, HSLA or 8-digit hex, from 0 (fully transparent) to 1, or 00 to FF in hex.
- Gamut
- The full range of colors a system can reproduce. Screen RGB and print CMYK have different gamuts, so some screen colors cannot be printed exactly.
- Additive vs subtractive
- RGB is additive (mixing light toward white), while CMYK is subtractive (layering ink on white paper toward black).
Frequently asked questions
How do I convert hex to rgb?
Split the six-digit hex into three pairs and convert each pair from base 16 to a 0 to 255 number. For example #337BFF becomes 33 = 51, 7B = 123 and FF = 255, giving rgb(51, 123, 255). This tool does it instantly when you paste the hex code.
What is #FFFFFF in rgb?
#FFFFFF is white, which is rgb(255, 255, 255). Each FF pair is the maximum channel value of 255, so all three primaries are at full strength, producing white.
How to convert rgb to hex?
Convert each channel to a two-digit hex number, then join them with a leading #. For each channel, divide by 16 for the first digit and take the remainder for the second, mapping 10 to 15 onto A to F. So rgb(255, 0, 0) becomes #FF0000.
What is HSL?
HSL stands for hue, saturation and lightness. Hue is an angle from 0 to 360 degrees on the color wheel, saturation is how vivid the color is from 0 to 100 percent, and lightness runs from 0 percent (black) through the pure color at 50 percent to 100 percent (white). It is popular with designers because it is easy to tweak.
Is hex the same as rgb?
Yes, in the sense that a hex code is just RGB written in base 16. Both describe the same red, green and blue channels. HEX packs them into a compact six-character string, while RGB writes them as three decimal numbers from 0 to 255, so they convert back and forth exactly.
How do I convert rgb to hsl?
Scale each RGB channel to a 0 to 1 range and find the largest and smallest. Lightness is the average of those two. Saturation depends on how far apart they are, and hue depends on which channel is largest. For example rgb(0, 128, 0) becomes hsl(120, 100%, 25%).
How do I convert hex or RGB to CMYK?
Scale each RGB channel to 0 to 1, set the black key K to 1 minus the largest channel, then compute cyan, magenta and yellow as (1 minus channel minus K) divided by (1 minus K), shown as percentages. Remember this is an approximation: screen and print use different color ranges, so check a printed proof. This tool shows the CMYK estimate automatically.
What is the difference between HSL and HSV?
Both start from the same hue angle, but HSL uses lightness, which reaches white at 100 percent, while HSV (also called HSB) uses value or brightness, which reaches the pure hue at 100 percent. They describe the same colors with different numbers, so an HSV value will not match an HSL lightness for the same color. HSV is common in editors like Photoshop, HSL in CSS.
How do I add transparency to a hex or rgb color?
Use an alpha channel. In CSS that is rgba(255, 0, 0, 0.5) for 50 percent opacity, or an 8-digit hex like #FF000080 where the last pair is the alpha from 00 (transparent) to FF (opaque). HSL has the same option as hsla(). The first six hex digits or three RGB numbers stay the same; only the alpha controls opacity.
Can I convert a named CSS color like "tomato" to hex?
Yes. CSS named colors map to fixed hex codes, so tomato is #FF6347, which is rgb(255, 99, 71). There are about 140 named colors. Once you know the hex code you can paste it here to get the RGB, HSL, HSV and CMYK versions.