CSS to OKLCH
← SkillSafe

Convert the colors in your CSS to OKLCH

Paste a stylesheet, drop a file or type a color. Every hex, rgb() and hsl() comes back as oklch(); nothing else changes.

or drop it here · .css, .scss, .less or .txt
No CSS handy? Try one:

How it works

  1. Paste or drop your CSS. A whole stylesheet, an SCSS or Less file, a Tailwind v4 @theme block, or just a list of colors, one per line.
  2. Every color is converted. Hex (#f00, #ff0000, #ff000080), rgb(), rgba(), hsl() and hsla() become oklch(L C H), with / alpha when they are see-through. An id selector such as #fad, comments, strings, url(), var() and calc() are left alone.
  3. Read the check. Text against its background in the same rule, with the WCAG 2 ratio and the APCA value, and HSL scales whose steps drift apart in hue once you can see their real hue.
  4. Copy or download. The converted file, the before/after table of every change as Markdown, or the changes as CSV.

Questions

What does it change?
Only color values: hex codes (#f00, #ff0000, #ff000080), rgb() and rgba(), hsl() and hsla(), in the comma form or the space form with a slash for alpha. Each becomes oklch(L C H), with / alpha when it is not fully opaque. Selectors, comments, strings, url(), gradients' structure, var() and calc() stay exactly as they were.
Is anything uploaded?
No. The conversion runs in your browser tab. Only the optional AI naming step sends anything, and it sends the list of colors with where each is used (property and selector), only when you press its button.
How exact is the conversion?
It uses the OKLab matrices from Björn Ottosson and the sRGB transfer curve, and writes L and C with 3 decimals and H with up to 3. #3b82f6 becomes oklch(0.623 0.188 259.815), the same as the reference tools. Three decimals are finer than a screen can show.
Do old browsers need a fallback?
oklch() works in every current browser (Baseline 2023). If you still support older ones, tick Keep the old value as a fallback: each converted line keeps its old value on the line before it, so a browser that does not understand oklch() uses the old one.
Why does the HSL scale get a warning?
HSL keeps the same hue number while the color you see shifts, often toward purple for blues. Once converted, the real hue of each step is visible. If the steps spread more than 10 degrees, the scale does not look like one color; giving every step the same oklch hue fixes it.