Hex Color Converter
Convert between HEX, RGB, HSL, and HSV color formats. Preview the color and get values for CSS, design, and development.
Did this tool work for you?
How to use this calculator
Colors can be expressed in multiple equivalent formats. HEX uses base-16; RGB uses decimal 0–255.
- 1
Enter RGB values (0–255 for each channel).
- 2
The calculator converts to HEX, HSL, and HSV automatically.
- 3
Use the HEX value in CSS, HSL for adjusting lightness/saturation, and RGB for image editing.
Frequently asked questions
Can I paste a hex code like #6366F1 into this tool?
No. The three input fields take the red, green and blue channel values as decimal numbers from 0 to 255, and the tool outputs the matching HEX, HSL and HSV. To go the other way by hand, split the hex code into pairs and convert each from base 16: 63 is 99, 66 is 102 and F1 is 241, which are the default values loaded in the fields.
What happens if I enter a number above 255 or below 0?
It is clamped into range rather than rejected. 300 becomes 255 and −5 becomes 0, so the input 300, −5, 12.9 produces #FF000C. Because the value is silently adjusted, check the RGB line in the output to see the channels that were actually used.
Are decimal channel values rounded?
They are rounded down, not to the nearest whole number: 12.9 becomes 12. Hex needs whole channel values, so fractional input from a design tool should be rounded the way you prefer before you enter it. Non-numeric input returns an error.
Why do HSL and HSV values look slightly off when I convert them back?
Hue is rounded to a whole degree, and saturation, lightness and value to whole percentages. That is enough precision for CSS, but converting the rounded HSL back to RGB can land one or two steps away from the original channels. The HEX line is the exact value; treat HSL and HSV as rounded descriptions.
What is the difference between HSL and HSV?
Both use the same hue angle but define the rest differently. HSL lightness runs from black through the pure colour at 50% to white, so pure red is hsl(0, 100%, 50%). HSV value measures brightness of the strongest channel, so pure red is hsv(0, 100%, 100%). CSS supports hsl() directly; it has no hsv() function, so that line is for design software.
Does it output transparency, 3-digit shorthand or named colours?
No. The output is always a six-digit uppercase hex, without an alpha channel and without shorthand like #F00, which equals #FF0000. It also does not match your colour to a CSS name or check contrast against another colour.
Why does grey show a hue of 0 and saturation 0%?
When red, green and blue are equal there is no dominant colour, so hue is undefined and the tool reports 0. #808080 gives hsl(0, 0%, 50%) and hsv(0, 0%, 50%). Changing the hue of such a colour in CSS has no visible effect until you also raise the saturation.
RGB to hex, HSL and HSV colour converter
How hex relates to RGB
A hex colour is three RGB channel values written in base 16, two digits each, in the order red, green, blue. A channel of 0 is 00 and 255 is FF. The converter takes the channel numbers, builds the six-digit code, and also works out hue, saturation, lightness and value. Hue is the position on the colour wheel from 0 to 360 degrees, which is why red is near 0, green near 120 and blue near 240.
| RGB | HEX | HSL | HSV |
|---|---|---|---|
| 255, 0, 0 | #FF0000 | hsl(0, 100%, 50%) | hsv(0, 100%, 100%) |
| 128, 128, 128 | #808080 | hsl(0, 0%, 50%) | hsv(0, 0%, 50%) |
| 0, 0, 0 | #000000 | hsl(0, 0%, 0%) | hsv(0, 0%, 0%) |
| 255, 255, 255 | #FFFFFF | hsl(0, 0%, 100%) | hsv(0, 0%, 100%) |
Worked example: an indigo button colour
The starting values 99, 102, 241 convert to #6366F1, hsl(239, 84%, 67%) and hsv(239, 59%, 95%). Hue 239 puts it in the blue-violet region, and the high saturation of 84% explains why it looks vivid. In a stylesheet you could keep the hex for the base colour, then derive a hover state by lowering the lightness in the HSL form, for instance hsl(239, 84%, 57%), which is much easier than guessing new hex digits.
Worked example: a green with mixed channels
Entering 46, 204, 113 produces #2ECC71, hsl(145, 63%, 49%) and hsv(145, 77%, 80%). The green channel is the largest, so the hue falls between 120 and 180 degrees. Compare the two lightness figures: HSL says 49% while HSV says 80%, because HSV measures the brightest channel (204 of 255) and HSL measures the midpoint of the largest and smallest channels. Pick the format that matches the tool you are pasting into.
Which format to use where
Use hex for compact, widely copied values in CSS, design handoffs and brand guides. Use HSL when you want to build tints and shades by changing one number. HSV appears mainly in colour pickers in graphics software, and CSS does not accept it. All four lines the tool prints describe the same colour, but HEX and RGB are exact while HSL and HSV are rounded.
Input rules
Each channel accepts 0 to 255. Out-of-range values are clamped and decimals are rounded down. Output is always uppercase hex with no alpha channel, so transparency has to be added separately, for example with an rgb() or eight-digit hex value written by hand.
Learn more from an authoritative source:
WikipediaVector Calculator
Add, subtract, and find the magnitude, dot product, and angle between 2D or 3D vectors.
Matrix Calculator (2×2)
Calculate the determinant, inverse, transpose, and eigenvalues of a 2×2 matrix.
Ohm's Law Calculator
Calculate voltage, current, resistance, or power using Ohm's Law. Enter any two values to find the other two instantly.
Projectile Motion Calculator
Calculate range, maximum height, time of flight, and velocity components for a projectile launched at any angle and speed. Assumes no air resistance.
Kinetic Energy Calculator
Calculate kinetic energy (KE) from mass and velocity, or find mass or velocity from a known kinetic energy value.
Work & Power Calculator
Calculate work done, power output, force, distance, or time using physics formulas. W = F × d and P = W / t.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →