Color Converter
oklch(54.6% 0.215 262.9)
- RGB
- rgb(37 99 235)
- RGBA
- rgba(37 99 235 / 1)
- HSL
- hsl(221 83.2% 53.3%)
- HSLA
- hsla(221 83.2% 53.3% / 1)
- HWB
- hwb(221 14.5% 7.8%)
- OKLCH
- oklch(54.6% 0.215 262.9)
- vs white
- 5.17:1AA large / UI: PassAA: PassAAA: Fail
- vs black
- 4.06:1AA large / UI: PassAA: FailAAA: Fail
- vs custom
- 1.15:1AA large / UI: FailAA: FailAAA: Fail
- Exact match
- blue-600
No history yet
Convert HEX to RGB, HSL, HWB and OKLCH
Paste a color in any CSS form: HEX with 3, 4, 6 or 8 digits (with or without #), rgb() or rgba(), hsl() or hsla(), hwb(), oklch(), a named color such as tomato, or transparent. Both the comma syntax and the CSS Color 4 space syntax work, and alpha can be 0–1 or a percentage. The tool returns HEX, RGB, RGBA, HSL, HSLA, HWB, OKLCH and the CSS color name when one matches, plus WCAG contrast, an 11-step OKLCH shade scale and the nearest Tailwind class. For example, #FF6347 converts to rgb(255 99 71), hsl(9 100% 63.9%) and oklch(69.6% 0.196 32.3), and its CSS name is tomato.
How to convert a color
- Paste or type a value into Color value. A pasted value converts at once; a typed value converts when you press Enter or leave the field. The field then shows the color as HEX.
- Read HEX, RGB, RGBA, HSL, HSLA, HWB and OKLCH beside it, plus a Named row when the color has an exact CSS name. Each row has a copy button; Copy all copies every format, one per line.
- Under Adjust, switch the sliders between HSL and OKLCH and drag them. Random picks an opaque color and Reset returns to #2563EB.
- Lower down, read WCAG contrast, click a step in Shades to copy its HEX, or copy the Nearest Tailwind color class. Recent keeps the last 8 colors.
- Export writes a CSS variable, a Tailwind v4 @theme variable in OKLCH and a Sass variable under the Variable name you type.
How to convert HEX to RGB and RGB to HEX by hand
A 6-digit HEX code is three base-16 pairs for red, green and blue. Convert each pair to decimal: FF = 15 × 16 + 15 = 255, 63 = 6 × 16 + 3 = 99, 47 = 4 × 16 + 7 = 71, so #FF6347 is rgb(255 99 71). A 3-digit code doubles each digit, so #F0A is #FF00AA. An 8-digit code adds an alpha pair: 80 is 128, and 128 / 255 ≈ 0.5 opacity. To go back from RGB to HEX, divide each channel by 16 and write the quotient and remainder as hex digits: 99 ÷ 16 = 6 remainder 3, so 99 is 63.
What is OKLCH?
OKLCH is a color space defined in CSS Color Module Level 4, written as lightness (0–100%), chroma (about 0–0.4) and hue (0–360°). It is designed to be perceptually uniform: equal numeric steps look like roughly equal visual steps. HSL is not; yellow at 50% lightness looks much brighter than blue at 50% lightness. That is why the shade scale here is built in OKLCH: eleven lightness targets from 97.5% down to 24% at the same hue, with chroma kept unless sRGB cannot show it. The step nearest your color is replaced by the color itself.
How does the WCAG contrast checker work?
The contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 and L2 are the relative luminance of the lighter and darker color (0.2126 R + 0.7152 G + 0.0722 B on linearized sRGB channels). WCAG AA requires at least 4.5:1 for body text and 3:1 for large text and UI components; AAA requires 7:1 for body text. The checker compares your color with white, black and a custom color. A color with alpha is blended onto each of them first, so rgb(0 0 0 / 0.5) measures 3.98:1 on white and 1.00:1 on black. Tomato (#FF6347) gives 2.95:1 on white, which fails AA for text, and 7.13:1 on black, which passes AAA.
Color conversion examples
- #2563EB → rgb(37 99 235), hsl(221 83.2% 53.3%), hwb(221 14.5% 7.8%) and oklch(54.6% 0.215 262.9). Entering 2563eb, rgb(14.5% 38.8% 92.2%) or oklch(0.546 0.215 262.9) gives the same color.
- rgb(37 99 235 / 0.5) or rgb(37 99 235 / 50%) → #2563EB80, hwb(221 14.5% 7.8% / 0.5) and oklch(54.6% 0.215 262.9 / 0.5). Entered as #2563EB80, the alpha reads 0.502, because 80 is 128 and 128 ÷ 255 = 0.502.
- oklch(70% 0.25 150) is outside sRGB and becomes #00C537. The OKLCH row then reads oklch(71.6% 0.225 145.1).
- #2563EB has 5.17:1 against white: AA passes, AAA fails. In its Shades row, step 700 (#0D4AD0) reaches 7.22:1 and passes AAA, while step 500 (#4481FF) has 3.60:1, enough for large text and UI components only.
- #777777 has 4.48:1 against white and fails AA for body text; #767676 has 4.54:1 and passes.
Rounding, round trips and out-of-gamut colors
HSL and HWB show hue as a whole degree and percentages to one decimal; OKLCH shows lightness to 0.1%, chroma to three decimals and hue to 0.1°. Rounded values do not always lead back to the same HEX: #2563EB is shown as hsl(221 83.2% 53.3%), and pasting that back gives #2564EB, because the exact hue is 221.2°. Across 140,608 colors (every fifth value of each RGB channel), the HSL row led back to a different HEX for about 42% and the OKLCH row for about 22%. Copy HEX or RGB when the value has to match. An OKLCH value outside sRGB is cut channel by channel to 0–255, which moves lightness and hue as well as chroma. Lowering chroma alone keeps both: oklch(70% 0.25 150) fits sRGB at a chroma of 0.193, which is #00BE58 instead of #00C537. The Shades row works that way; the converter itself does not. Contrast is calculated on the opaque color: rgb(37 99 235 / 0.5) reports the same 5.17:1 as #2563EB, although on a page a half-transparent color blends with whatever is behind it.
Common color conversion mistakes
- Writing OKLCH lightness as a bare number from 0 to 100. oklch(54.6 0.215 262.9) is rejected; write 54.6% or 0.546. Chroma can be a number or a percentage, where 100% is 0.4.
- Leaving out the percent signs in HSL or HWB. hsl(221, 83, 53) is rejected. Hue takes a plain number or a deg, rad or turn unit and wraps around, so -139 and 581 both mean 221.
- Pasting lab(), lch(), oklab() or color(display-p3 …). Only HEX, rgb(), hsl(), hwb(), oklch() and color names are read. Out-of-range values such as rgb(300 0 0) are errors too, not clamped as in CSS.
- Dragging OKLCH Lightness past what sRGB can show. From #2563EB, setting Lightness to 90 gives #90D8FF, and the sliders jump to 85% lightness and a hue of 233. Lower Chroma first, or take a light step from Shades.
- Exporting a transparent color. Export and Recent drop the alpha: rgb(37 99 235 / 0.5) exports as --color-primary: #2563EB. Copy the HEX or OKLCH row to keep it.
FAQ
Why are some OKLCH colors marked as clipped?
OKLCH can describe colors outside the sRGB gamut that HEX and RGB can represent. When the chroma is too high for a given lightness and hue, each RGB channel is clamped to 0–255 and the result is marked as clipped. For example, oklch(70% 0.4 30) becomes #FF0000, which is close but not identical to the requested color.
Why use OKLCH instead of HSL for design tokens?
In OKLCH, the same lightness value looks about equally light across hues, so a scale built by stepping lightness stays visually even. In HSL, hsl(60 100% 50%) yellow and hsl(240 100% 50%) blue share 50% lightness but look very different, so scales drift.
What WCAG contrast level should I aim for?
AA is the usual target: 4.5:1 for body text and 3:1 for large text (24 px, or 18.66 px bold) and UI components. Accessibility rules such as US Section 508 and the EU standard EN 301 549 reference WCAG level AA. AAA (7:1 for body text) is stricter and is often used for long-form reading.
What is the difference between RGB and RGBA?
RGBA adds an alpha (opacity) channel from 0 to 1. In CSS Color 4, rgb() also accepts alpha, as in rgb(255 99 71 / 0.5), so rgba() is kept for older code. The same applies to hsl() and hsla(). In HEX, alpha is the fourth or eighth digit pair, as in #FF634780.
How do I convert RGBA to HEX?
Convert R, G and B to two-digit HEX as usual, then multiply the alpha by 255, round, and convert that too: 0.5 × 255 = 127.5, which rounds to 128, or 80 in HEX. So rgba(255, 99, 71, 0.5) becomes #FF634780. Paste an rgba() value here and the HEX row shows the 8-digit code; a fully opaque color gives the 6-digit form.
How is the nearest Tailwind color chosen?
The tool measures the distance in OKLCH between your color and each shade of Tailwind's default palette (22 hues × 11 shades) and picks the closest. A distance below 0.005 is shown as an exact match; #2563EB, for example, is exactly blue-600.
Can I share a color via URL?
Yes. The URL hash updates as you change the color, so copying the address bar gives a link that opens the same color.
Related tools
Related articles
- K-means Belongs in CIELAB, Not RGB: Picking Five Colors From an Image That Look Right
K-means on RGB pixels returns muddy browns; in CIELAB it returns the colors a designer would pick. Why, plus code: a 256-entry LUT and a 3×3 matrix.