Skip to main content

Color Converter

Convert colors between HEX, RGB, HSL and OKLCH, and check WCAG AA and AAA contrast ratios for text and background colors. Free and runs in your browser.

Color

Stays in your browser

Converted values

  • HEX#6366f1
  • RGBrgb(99, 102, 241)
  • HSLhsl(239, 84%, 67%)
  • OKLCHoklch(0.585 0.204 277.1)
  • Nearest Tailwindindigo-500

WCAG Contrast Checker

Sample text on this background

Contrast ratio: 14.63:1

AA Normal ✓AA Large ✓AAA Normal ✓AAA Large ✓

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Online Color Converter & Contrast Checker

Convert a color between HEX, RGB, HSL, and OKLCH, or check the WCAG 2.1 contrast ratio between two colors for accessibility compliance. It helps designers and frontend developers translate color formats and check whether interface text meets contrast expectations.

Color spaces explained

HEX and RGB represent a color as red, green, and blue channel values — HEX is just RGB written in base-16. HSL (hue, saturation, lightness) is often more intuitive for humans to reason about and adjust. OKLCH (lightness, chroma, hue) is a newer, perceptually uniform space — a given change in its lightness value looks like the same brightness change to the human eye anywhere in the color space, which isn't true of HSL's lightness.

How WCAG contrast checking works

The checker computes each color's relative luminance using the WCAG 2.1 formula, then calculates the contrast ratio between the lighter and darker color. A ratio of 21:1 (pure black on pure white) is the maximum possible; 1:1 means the colors are identical. The four badges show whether your combination meets each WCAG conformance level and text size threshold.

Common use cases

  • Checking whether a design's text/background color combination meets accessibility requirements before shipping
  • Converting a design tool's HEX value into the CSS color format your codebase uses
  • Building a perceptually uniform color scale using OKLCH's lightness axis

Worked example

#6366f1 converts to rgb(99, 102, 241), hsl(239, 84%, 67%), and oklch(0.585 0.204 277.1). Checking #1e293b as foreground against #ffffff as background gives a contrast ratio of 14.63:1 — well past every WCAG threshold (AA and AAA, normal and large text all pass).

Common mistakes and edge cases

  • Colours outside the sRGB range, such as a very saturated oklch() or a lab() value, are shown as the closest sRGB colour with a note, so converting back does not give exactly the same numbers.
  • When a pair fails AA or AAA, "Suggested fixes" shows the nearest colour with the same hue that passes. It only changes lightness, so the result keeps the look of your colour. If the other colour is a mid-grey, no lightness may pass, and you will be told to change the other colour.
  • "Nearest Tailwind" compares your colour to the Tailwind colour names (v3 values) by how different they look. Newer Tailwind v4 shades are slightly different, so treat the name as a close match, not an exact one, unless it says exact.
  • A colour with transparency is shown with its alpha: rgb(99 102 241 / 50%) becomes #6366f180. The swatch and the contrast checker use the solid colour.

Frequently asked questions

What is OKLCH and why would I use it over HEX or HSL?
OKLCH is a newer, perceptually uniform color space — meaning equal changes in its Lightness value look like equal changes in brightness to the human eye, which isn't true for HSL. It's increasingly used in modern CSS (the color() and oklch() functions) for building color scales and palettes that look visually consistent.
What do AA and AAA mean for contrast?
These are WCAG 2.1 conformance levels for text contrast against its background. AA (the more commonly required level) needs a 4.5:1 ratio for normal text and 3:1 for large text (18pt+, or 14pt+ bold); AAA is stricter, requiring 7:1 for normal text and 4.5:1 for large text.
Which color counts as the "foreground" vs "background"?
It doesn't actually matter which one you call foreground or background — the contrast ratio formula is symmetric, comparing the lighter color's luminance to the darker one's regardless of which field you entered them in.
Is this the exact same contrast calculation used by accessibility auditing tools?
Yes — it implements the WCAG 2.1 relative luminance and contrast ratio formulas directly from the specification, the same formulas used by tools like Lighthouse, axe, and browser DevTools' accessibility panels.
Can I paste an hsl() or oklch() string into the color field to convert it?
Yes. The colour box reads #rgb, #rgba, #rrggbb and #rrggbbaa, rgb() and rgba() with commas or spaces (with / alpha and percentages), hsl(), hwb(), lab(), lch(), oklab(), oklch() and CSS colour names such as rebeccapurple.
Which color format should I use in CSS?
For most web work HEX or RGB is the safe choice because every browser and design tool understands it. HSL is easier to adjust by hand (lighten or darken a colour), and newer formats such as OKLCH give more even results across the colour range but need a recent browser. Pick one format and use it everywhere in the project.

Related tools

More Frontend & Design

View all Frontend & Design tools →