HEX to RGB and RGB to HEX converter
Paste a HEX code like #a855f7 and convert HEX to RGB and HSL instantly.
- Free, no sign-up
- No upload
- Full resolution kept
How it works
Three steps, under a minute
Paste a HEX code like #a855f7 and convert HEX to RGB and HSL instantly. Paste rgb() and get the HEX code back, which is RGB to HEX. You also see the contrast against white and black, so you know if text in that colour will be readable.
- 1
Add your files
Type or paste a colour. A HEX color to RGB works with #a855f7; you can also use rgb(168, 85, 247) or hsl(271, 91%, 65%).
- 2
Process
Read the HEX, RGB and HSL values; copy whichever you need.
- 3
Download
Check the contrast lines before using the colour for text.
What you get
Everything you need, nothing uploaded
A colour converter for HEX, RGB and HSL
3 and 6 digit HEX, rgb() and hsl() input, plus a colour picker.
HEX to HSL, HSL to HEX and RGB to HSL, plus normalised 0 to 1 RGB output.
WCAG contrast ratio on white and on black with pass or fail notes.
No upload, no account.
In depth
Which form to use where
| Form | Use |
|---|---|
| HEX (#rrggbb) | CSS, design tools, brand guidelines |
| rgb(r, g, b) | CSS with alpha (rgba), canvas and most programming APIs |
| hsl(h, s%, l%) | CSS when you want to tweak lightness or saturation without changing the hue. Convert HEX to HSL here, adjust, then convert back |
| 0 to 1 floats | Shaders, game engines and some graphics libraries |
Settings
How HEX colour codes work
A HEX code is # followed by six characters: #rrggbb. Each pair is one colour channel, red then green then blue, written in base 16. A pair runs from 00 (0) to ff (255).
Worked example, #a855f7. a8 is 10 x 16 + 8 = 168. 55 is 5 x 16 + 5 = 85. f7 is 15 x 16 + 7 = 247. So #a855f7 is rgb(168, 85, 247). To go back, turn each number into two hex digits: 168 is a8, 85 is 55 and 247 is f7.
A short code like #fff is shorthand: each digit is doubled, so #fff is #ffffff.
In depth
Reading the contrast numbers
WCAG asks for a contrast of at least 4.5:1 between text and its background for normal text and 3:1 for large text. The two contrast lines show the ratio of your colour on white and on black. If both fail, the colour works for decoration but not for text.
FAQ
Frequently asked questions
Can’t find an answer? The guides cover formats, sizes and privacy in depth.
Read the guidesWhat is the RGB of #ffffff?
rgb(255, 255, 255), pure white. Type it in and the swatch confirms it.
Is HEX the same as RGB?
They describe the same colour in two notations. HEX writes the red, green and blue values in base 16 (#a855f7). RGB writes them in plain numbers from 0 to 255 (rgb(168, 85, 247)).
How do HEX colour codes work?
The code is three pairs of characters after a #. The pairs are red, green and blue. Each pair is a number from 0 to 255 written in base 16, so ff means 255 and 00 means 0.
How do I convert RGB to HEX by hand?
Turn each of the three numbers into two hex digits and join them after a #. Divide by 16: the whole part is the first digit and the remainder is the second. 168 is 10 and 8, which is a8. Use a to f for 10 to 15.
Can I convert HSL to HEX?
Yes. Type hsl(271, 91%, 65%) and the HEX and RGB values appear with copy buttons.
Does it support transparency (RGBA)?
No. It converts the colour only. If you paste rgba(), the alpha value is ignored, and 8-digit HEX codes are not accepted.
Why does HSL help?
HSL separates hue from lightness and saturation, so making a colour lighter or more muted is a single number change. Converting HEX to HSL, adjusting, and converting back is the usual workflow.
Can I pull colours from a photo?
Yes, with the colour palette tool, which extracts the dominant colours and lets you pick any pixel.
Sources
Sources and further reading
Links checked 13 November 2026. Outside pages change, so check the date on them.
Related tools
More free tools
Navy blue hex code: #000080, with RGB, CMYK and color code Sage green hex code: #9CAF88, with color code and palette Teal hex code: #008080, with RGB, CMYK and color code Burgundy hex code: #800020, with color code and contrast
Done here? Make it look great.
Adjust, retouch and add effects in the full editor. Still 100% on your device.