Color Converter

HEX ↔ RGB ↔ HSL ↔ OKLCH with WCAG contrast checks.

Runs in your browser Instant No sign-up
Colors

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use it

Paste one or more colors, one per line. Each color is converted to every format:

HEX       #5b5bf0
RGB       rgb(91 91 240)
HSL       hsl(240 83% 65%)
OKLCH     oklch(0.561 0.218 276.8)
Name      none — nearest is royalblue
On white  5.00:1 — AA
On black  4.20:1 — AA large text only

The Preview tab shows a swatch for every color, labeled with its hex value in whichever text color reads better on it. The Converted tab holds the text above for copying. Up to 24 colors are converted at once, which is handy for checking a whole palette.

Contrast checks

Every color is measured against white and black using the WCAG 2 relative luminance formula:

Ratio Level Good for
7:1 or more AAA Body text, strict requirements
4.5:1 or more AA Normal body text
3:1 or more AA large text only Headings, large UI labels, icons
below 3:1 fails Decoration only

For example, tomato scores 2.95:1 on white (fails) but 7.13:1 on black (AAA), so it works as a background for dark text but not as text on a white page.

Formats in practice

  • HEX is the most portable. Eight-digit hex includes alpha, so #ff000080 is red at about 50% opacity.
  • RGB and HSL use the modern space-separated syntax (rgb(91 91 240)), which every current browser supports. Alpha is written after a slash.
  • OKLCH gives lightness from 0 to 1, chroma and hue in degrees. Colors with very high chroma may fall outside sRGB. For example, oklch(0.9 0.4 150) is clipped to #00ff00 with a warning.

If a line can’t be parsed, you get a hint with example formats. In batch mode, the other colors are still converted.

Building accessible palettes

A practical workflow is to pick a brand color, paste it together with a few lighter and darker variants, and read the contrast lines for each one. Keep the variants that reach AA for the way you plan to use them: text on white, text on dark backgrounds, or large headings only. Varying only the lightness in OKLCH keeps the hue looking the same across the scale, which is why many design systems now define their tokens in oklch() and fall back to hex for older tools.

Frequently asked questions

Which color formats can I paste?

Hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb() and rgba(), hsl() and hsla(), hwb(), oklch(), oklab() and all 148 CSS color names such as tomato or rebeccapurple. Both comma and space syntax work, and alpha can be written with a slash.

What do AA and AAA mean?

They are WCAG 2 contrast levels for text. AA requires 4.5:1 for normal text and 3:1 for large text (at least 24px, or 18.66px bold). AAA requires 7:1. The tool reports the ratio of your color against white and against black and names the level it meets.

Why use OKLCH?

OKLCH is perceptually uniform: changing lightness by the same amount looks like the same change for every hue, which HSL doesn't do. That makes it easier to build palettes and hover states. All modern browsers support oklch() in CSS.

What does outside the sRGB gamut mean?

OKLCH can describe colors that ordinary screens and hex codes can't show. When that happens the tool warns you and clips the values to the nearest color that fits in sRGB for the HEX, RGB and HSL rows.

How is the color name chosen?

The tool finds the CSS named color that is closest in the OKLab color space. An exact match is shown as is, a near match (ΔE below 0.03) as ≈ name, and anything further away as none — nearest is name, so you never mistake a distant color for a named one.

Last updated