Developer Tools
Color Converter
Enter a HEX, RGB or HSL color (or pick one) to instantly see it in all three formats, with a live preview swatch and one-click copy for each.
HEX
#2563eb
RGB
rgb(37, 99, 235)
HSL
hsl(221, 83%, 53%)
How to convert a colour between HEX, RGB and HSL
- Type a colour into the box: a 3- or 6-digit hex code with or without the hash, an rgb() value, or an hsl() value such as hsl(221, 83%, 53%). Or click the small swatch next to the box to open your browser's colour picker.
- Watch the preview bar and the three rows update as you type. Nothing needs to be submitted.
- Press Copy on the HEX, RGB or HSL row you need; the button shows a tick for a second.
- If the text is not a colour the tool understands, a red line asks for a valid hex, rgb() or hsl() value, and the swatch keeps the last colour that parsed until you fix it.
Input formats the parser accepts
Leading and trailing spaces are trimmed and letter case does not matter. Hues outside 0 to 360 wrap around, so hsl(381, 83%, 53%) is the same as hsl(21, 83%, 53%), while a saturation or lightness above 100% is rejected rather than clamped. The HEX output is always lowercase with a leading hash, RGB is written as rgb(r, g, b) and HSL as hsl(h, s%, l%).
| You type | Accepted? | Read as |
|---|---|---|
| #2563eb | Yes | rgb(37, 99, 235) |
| 2563EB (no hash, any case) | Yes | rgb(37, 99, 235) |
| #fff or #f00 (short hex) | Yes | Each digit is doubled: #fff is #ffffff |
| rgb(37, 99, 235) | Yes | Integers 0 to 255 separated by commas |
| rgba(37, 99, 235, 0.5) | Yes | The alpha value is ignored |
| rgb(37 99 235 / 0.5) (space syntax) | Yes | Spaces work like commas; the slash alpha is ignored |
| rgb(15%, 39%, 92%) | Yes | Each percentage is scaled to 0 to 255: rgb(38, 99, 235) |
| hsl(221, 83%, 53%) | Yes | Converted to RGB first: rgb(36, 99, 235) |
| hsla(221, 83%, 53%, 0.5) or hsl(221deg 83% 53% / 0.5) | Yes | Alpha ignored; deg, rad, grad and turn units are accepted on the hue |
| red, dodgerblue, transparent | No | Named colours are not parsed |
| #2563ebff (8-digit hex) | No | Alpha channels are not supported |
RGB to HSL, worked through for #2563eb
Start from rgb(37, 99, 235) and divide each channel by 255: R = 0.145, G = 0.388, B = 0.922. The largest is B at 0.922, the smallest is R at 0.145, and their difference (delta) is 0.776.
Lightness is the midpoint of the largest and smallest: (0.922 + 0.145) ÷ 2 = 0.533, shown as 53%. Saturation is delta ÷ (1 − |2L − 1|) = 0.776 ÷ (1 − 0.067) = 0.776 ÷ 0.933 = 0.832, shown as 83%. Hue depends on which channel is largest; with blue on top it is ((R − G) ÷ delta + 4) × 60 = ((0.145 − 0.388) ÷ 0.776 + 4) × 60 = (−0.313 + 4) × 60 = 221.2, shown as 221. The result is hsl(221, 83%, 53%).
Hue is rounded to a whole degree and saturation and lightness to whole percentages, so feeding the HSL string back into the box can land a unit away in one channel: hsl(221, 83%, 53%) comes back as rgb(36, 99, 235), one step short of the original red value of 37. For an exact round trip, keep the hex or RGB value.
Reference colours in all three formats
Greys have no dominant channel, so delta is zero and the tool reports a hue of 0 and a saturation of 0% for them; only the lightness carries information.
| Colour | HEX | RGB | HSL |
|---|---|---|---|
| White | #ffffff | rgb(255, 255, 255) | hsl(0, 0%, 100%) |
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) |
| Mid grey | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) |
| Red | #ff0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) |
| Yellow | #ffff00 | rgb(255, 255, 0) | hsl(60, 100%, 50%) |
| Cyan | #00ffff | rgb(0, 255, 255) | hsl(180, 100%, 50%) |
| Magenta | #ff00ff | rgb(255, 0, 255) | hsl(300, 100%, 50%) |
| Default blue | #2563eb | rgb(37, 99, 235) | hsl(221, 83%, 53%) |
Choosing a format for the job
- Hex is the compact form that design tools, brand guidelines and most CSS codebases expect, and it is what the native picker swatch next to the box works in.
- RGB is handy when you will add transparency by hand, since you can write rgba(37, 99, 235, 0.5) around the numbers shown.
- HSL makes programmatic variations easy: keep hue and saturation and move lightness up for hover states or down for pressed states.
- iOS and Android code often wants channels as fractions of 1: divide each RGB value by 255, so 37 becomes 0.145.
What is out of scope
The converter has no alpha channel, no CMYK or LAB output and no colour names. When the text box holds something unparseable, the red line appears and the native picker swatch stays on the last colour that parsed instead of jumping to black. The picker dialog itself is provided by your browser and operating system, so it looks different on Windows, macOS and phones.
Frequently asked questions
How do I convert HEX to RGB?
Each pair of hex digits is the red, green and blue value in base 16. For example #2563eb is red 0x25 (37), green 0x63 (99), blue 0xeb (235) — rgb(37, 99, 235). This tool does it instantly.
What is HSL?
HSL stands for Hue, Saturation and Lightness. It describes a color the way people think about it — its base color, how vivid it is, and how light or dark — which makes it handy for designers.
Can I type an HSL value to convert it to hex?
Yes. Type hsl(221, 83%, 53%) or an hsla() value, with commas or spaces, and the HEX and RGB rows update. Because the HSL string is rounded to whole units, the hex can sit one step away from a colour that was first entered as hex.
Why is the hue 0 for grey, black and white?
With equal red, green and blue there is no dominant channel, so hue is undefined. The tool reports 0 for hue and 0% for saturation in that case.
Does it support transparency?
No. An rgba() value is accepted but the alpha is dropped, and 8-digit hex codes are rejected. Add the alpha yourself to the copied value.
Does it accept a hex code without the hash sign?
Yes. 2563eb and #2563eb give the same result, and uppercase letters are fine too. The HEX row always shows the lowercase form with the hash.
Explore
113 tools. Zero uploads. One place.
Every tool opens instantly, works on your phone and keeps your files on your device.
Color Converter guides
Related tools
JSON Formatter
Developer Tools
Format, validate and minify JSON instantly.
Open toolBase64 Encode / Decode
Developer Tools
Encode text to Base64 or decode it back.
Open toolURL Encode / Decode
Developer Tools
Percent-encode or decode URLs and query strings.
Open toolUUID Generator
Developer Tools
Generate random UUID (v4) identifiers in bulk.
Open tool