Skip to content
gohacks.dev
Web

Color Converter

Convert a colour between HEX, RGB, HSL and OKLCH, including alpha, with a picker, a swatch and the Tailwind arbitrary-value class.

Free · No sign-up · Your inputs stay in your browser

Input

Convert colours: HEX, RGB, HSL and OKLCH

Output

#0f766e

HEX

#0f766e

RGB

rgb(15 118 110)

RGB (legacy)

rgb(15, 118, 110)

HSL

hsl(175.3 77.4% 26.1%)

OKLCH

oklch(51.09% 0.0861 186.39)

Tailwind arbitrary

bg-[#0f766e]

OKLCH is perceptual: the same L looks equally light whatever the hue, which is why Tailwind v4 defines its palette in it and why this site builds its colour presets with it. A colour outside the sRGB gamut is clipped to the nearest one when converted to hex.

Runs in this browser. Nothing you paste is sent to a server.

Why OKLCH

In HSL, yellow and blue at the same lightness look nothing alike. OKLCH is built so that equal lightness looks equally light across hues, which makes it the space to build palettes and dark modes in: change L to make a tint, keep C and H to keep the colour. Tailwind CSS v4 defines its default palette in OKLCH, and CSS Color 4 made it a CSS function.

Modern syntax

rgb(37 99 235 / 50%), with spaces and a slash for alpha, is the current syntax, and the comma form with rgba() remains valid. Every current browser supports both, and oklch() since 2023.

Share

Frequently asked questions

How do I convert hex to RGB?
Each pair of hex digits is one channel: #0f766e is 0x0f, 0x76 and 0x6e, or rgb(15 118 110).
What does the fourth pair in an 8-digit hex colour mean?
Alpha: 00 is transparent and ff is opaque, so #2563eb80 is about 50 percent opacity.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools