HEX to RGB Converter — Plus HSL, HSV & OKLCH
- This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.
Any colour
Accepts HEX (3, 4, 6 or 8 digits), rgb(), hsl(), hsv(), oklch() and common colour names like “teal”.
Formats
- HEX
- #0f766e
- RGB
- rgb(15, 118, 110)
- HSL
- hsl(175, 77%, 26%)
- HSV
- hsv(175, 87%, 46%)
- OKLCH
- oklch(51.1% 0.086 186.4)
Contrast (WCAG)
AA needs 4.5:1 for body text (3:1 for large text); AAA needs 7:1. Recommended text colour on this background: white.
About this tool
Paste a colour in whatever format you have — #ff6600, rgb(255 102 0), hsl(24 100% 50%), oklch(…) or a name like “teal” — and get it in every other format at once, each ready to copy. Commas and spaces both work, as do rgba(), hsla(), hsv(), hsb() and percentages inside rgb(). The result updates as you type.
For example, #1e40af becomes rgb(30, 64, 175), hsl(226, 71%, 40%), hsv(226, 83%, 69%) and oklch(42.4% 0.181 265.6). The conversion runs in every direction, so hsl(24 100% 50%) comes back as #ff6600, and oklch(70% 0.2 150) — a green outside the sRGB range — is clamped to the nearest displayable colour, #00bf54.
Short hex codes (#f60) and hex with alpha (#ff660080) are understood too, and alpha is carried through to the hex, rgb(), hsl() and oklch() output in the modern slash syntax, for example rgb(255 102 0 / 0.5). HSV has no alpha form, so that line is always opaque. The colour names covered are the common ones — teal, navy, coral, tomato, rebeccapurple and so on — not the full CSS list.
A swatch confirms you have the colour you expect, with an Adjust field to nudge it, and the contrast panel tells you whether white or black text is readable on it, with WCAG AA and AAA badges. This page is for a value you already have. To explore colours, build a 50–950 palette or pick a colour off the screen, use the Colour Picker; to compare two colours of your own, use the Colour Contrast Checker. Nothing is sent anywhere — the maths runs in your browser.
Frequently asked questions
How do I convert HEX to RGB by hand?
Split the six digits into three pairs and convert each from hexadecimal: #ff6600 → ff=255, 66=102, 00=0, so rgb(255, 102, 0).
What is the 8-digit hex format?
The last two digits are alpha (opacity): 00 is fully transparent and ff fully opaque. #ff660080 is the same orange at about 50% opacity.
What is the difference between HSL and HSV?
Both share the same hue. In HSL, 100% lightness is always white; in HSV (also called HSB), 100% value at full saturation is the pure hue. Design apps show HSB, but CSS supports hsl() and not hsv(), so convert before pasting into a stylesheet.
Why does my OKLCH colour come back slightly different?
OKLCH can describe colours that no sRGB screen can show. When a value falls outside that range the converter clamps each channel, so the hex you get is the closest displayable colour and converting it back gives slightly lower chroma.
Which colour format should I use in CSS?
Any works. HEX is the most common; HSL is easier to adjust by hand; OKLCH gives the most consistent lightness when building palettes.