# CSS to OKLCH > Free converter that runs in the browser: paste a stylesheet (CSS, SCSS, Less or a Tailwind v4 @theme block), drop a file, or type a list of colors, and get the same text back with every hex, rgb(), rgba(), hsl() and hsla() color rewritten as oklch(). Everything else is left exactly as it was. Nothing is uploaded. An optional, metered AI step names the colors as CSS variables for their job. URL: https://css-to-oklch.skillsafe.ai/ API: https://css-to-oklch.skillsafe.ai/api.html ## What the free converter does (in the browser, no sign-in) - Finds colors only inside declaration values: hex with 3, 4, 6 or 8 digits, rgb()/rgba() and hsl()/hsla() in the comma form or the space form with "/ alpha", with numbers, percentages and hue units (deg, turn, rad, grad). Selectors (an id such as #fad), comments, strings, url(), and colors built with var(), calc() or relative color syntax are left alone and listed. - Converts with the OKLab matrices (Ottosson) and the sRGB transfer curve. Writes oklch(L C H) with L and C to 3 decimals and H to up to 3, trailing zeros dropped; greys get C 0 and H 0; alpha below 1 is written "/ alpha". Example: #3b82f6 -> oklch(0.623 0.188 259.815); rgba(0, 0, 0, 0.1) -> oklch(0 0 0 / 0.1). - Options: lightness as a number (0.623) or a percentage (62.3%); keep the old value as a fallback (the old declaration stays on the line before the new one; variables get no fallback because a later variable always wins); also convert the 148 CSS color names; put the colors in variables (a :root block of --color-1, --color-2 ... placed after any @import, with the rules using var(); colors already inside a custom property or SCSS/Less variable stay where they are). - Checks: text against its background in the same rule (color with background or background-color), with the WCAG 2 contrast ratio and the APCA Lc value, flagged below 4.5:1 or Lc 60; HSL scales (three or more steps with one hue and saturation) whose converted hues spread more than 10 degrees. - Shows a before/after table of every change with line numbers and swatches, and the list of different colors. - Copy or download: the converted file (name.oklch.css, .scss or .less), the change table as Markdown, or the changes as CSV (line, property, before, after, hex, L, C, H, alpha). ## Optional AI step (sign-in, metered) Task id `name`. Sends each color used in an ordinary property (at most 60, the most used first): an id, its oklch() value, hex, alpha, how often it is used and up to four "property in selector" places, plus the variable names the stylesheet already defines. The model returns JSON {"tokens": [{"id", "name", "role"}]} with a --color-... name and a role (brand, accent, text, text-muted, background, surface, border, success, warning, danger, info, overlay, other). The page refuses unknown ids, a second name for one color, names that are not lowercase hyphenated custom properties, numbered names, duplicates and names the stylesheet already uses, keeps a numbered name for any color left out, and lists every refusal. The model never supplies a color value. ## Sources Adapted from the agent skill @jakubkrehel/oklch-skill (MIT), https://skillsafe.ai/skill/@jakubkrehel/oklch-skill, from github.com/jakubkrehel/oklch-skill.