How to convert HEX to RGB (or RGB to HEX)
The tool works out which notation you pasted, so you don't pick a direction. Every format is calculated from the same value.
- Paste or type a value into Color to convert:
#1e90ff,rgb(30, 144, 255),hsl(210, 100%, 56%), or just30, 144, 255. - Read the six cards under Every format: HEX, HEX8, RGB, RGBA, HSL and HSLA. They update as you type, so you don't need to press Convert.
- Click Copy on a card to copy that one string, for example
rgb(30, 144, 255)to paste into a stylesheet. - To adjust the color instead of typing it, use Pick a color or drag the Red, Green, Blue and Alpha sliders. If Alpha is below 1, the input switches to an
rgba()value. At full opacity it switches to a 6-digit hex. - To get all formats plus both contrast ratios as plain text, use Copy all. The text keeps the same English labels (
HEX: …,Contrast vs white: …) whatever language the page is in.
Worked examples
A HEX code like Dodger Blue, converted to the other formats:
Input: #1e90ff
HEX: #1e90ff
HEX8: #1e90ffff
RGB: rgb(30, 144, 255)
HSL: hsl(210, 100%, 56%)
Contrast vs white: 3.24 (AA Large)
Contrast vs black: 6.49 (AA)
An RGB color with transparency, written in the modern space-and-slash syntax:
Input: rgb(255 136 0 / 50%)
HEX: #ff8800
HEX8: #ff880080
RGBA: rgba(255, 136, 0, 0.5)
HSLA: hsla(32, 100%, 50%, 0.5)
The plain HEX card drops the alpha. Only HEX8, RGBA and HSLA keep it.
Some other inputs and what they give:
| Input | HEX | RGB | HSL |
|---|---|---|---|
#f80 |
#ff8800 |
rgb(255, 136, 0) |
hsl(32, 100%, 50%) |
teal |
#008080 |
rgb(0, 128, 128) |
hsl(180, 100%, 25%) |
#336699 |
#336699 |
rgb(51, 102, 153) |
hsl(210, 50%, 40%) |
hsl(400, 50%, 50%) |
#bf9540 |
rgb(191, 149, 64) |
hsl(40, 50%, 50%) |
Hues above 360° wrap around, so 400 is read as 40.
When you'd reach for it
- Moving a brand color from a design file into code. A designer gives you
#336699, but your theme variables usehsl()so you can change lightness. Copy the HSL card and edit only the last number. - Checking a button label before shipping. Teal (
#008080) scores 4.77:1 on white, which passes AA for body text. Orange#ff8800scores 2.39:1 on white, which fails, but 8.77:1 on black. That means dark text on an orange button is the readable choice. - Building hover and pressed states. The Lighter and darker row gives five shades of the same hue and saturation at 10%, 30%, 50%, 70% and 90% lightness. For
#ff8800they are#331b00,#995200,#ff8800,#ffb866and#ffe7cc. Click one to load it and convert it. - Reading a semi-transparent overlay. A token like
#00000080shows up asrgba(0, 0, 0, 0.5), so you can see the opacity right away.
When you have the colors you need, you can turn them into a full scheme with the Color Palette Generator or a background with the CSS Gradient Generator. The article How to Build a CSS Gradient: Angles, Stops and Fallbacks covers what to do with hex stops after that.
Limits and edge cases worth knowing
- Named colors: only the 16 basic CSS names are recognised (
black,silver,gray,white,maroon,red,purple,fuchsia,green,lime,olive,yellow,navy,blue,teal,aqua). Extended names such asorangeorrebeccapurpleshow an error. Enter their hex codes instead. - HSL is rounded: the tool rounds HSL to whole degrees and percents, so a round trip can be off by one per channel.
#1e90ffshows ashsl(210, 100%, 56%), but typing that HSL back in gives#1f8fff. Copy HEX or RGB when you need the exact value. - Out-of-range values are rejected: RGB channels must be 0–255 (or 0%–100%), saturation and lightness 0%–100%, and alpha 0–1.
rgb(300, 0, 0)shows an error rather than being clamped to 255. - Alpha uses two decimals: the tool stores opacity in hundredths, so a few 8-digit hex alphas shift by one step (for example
81comes back as82). - The color picker has no alpha: picking a color from the native picker replaces the input with a 6-digit hex, which resets transparency to opaque.
- Only sRGB notations: there's no
hwb(),lab(),oklch(), CMYK or Pantone. For the full CSS syntax, see MDN's<color>reference.