Color Converter — HEX, RGB, HSL & OKLCH
Convert HEX to RGB, HSL, OKLCH, OKLAB and CMYK in your browser — copy any format with one click. Free, no signup, your colors never leave the page.
Color blindness simulation (8 types)
Tints / Shades / Tones / Harmonies
Tints
Shades
Tones
Harmonies
Copy as code
— — — — — Common colors reference
What Is a Color Converter?
A color converter is a small utility that translates a single color value between the formats your toolchain, your design system, and your browser actually understand — HEX, RGB, HSL, HSV, HWB, CMYK, OKLCH, OKLAB, and the 148 CSS named colors. Online converters have been a staple of web tooling since the early 2000s, back when the answer was almost always a simple HEX-to-RGB textbox built for a Geocities-era stylesheet. What separates a modern converter from those legacy tools is three things: a unified-field UX where every format is simultaneously editable instead of a one-direction dropdown, an OKLCH source-of-truth that holds the canonical value internally so round-trips stay bit-stable, and perceptual math grounded in W3C CSS Color 4 instead of the gamma-tangled HSL arithmetic the 2003 generation shipped.
Different color spaces exist because different problems need different representations, and no single space is good at all of them. RGB is hardware-native — it maps directly to the red, green, and blue subpixels of an LCD or the phosphors of a CRT, with each channel encoded as an 8-bit integer from 0 to 255. HEX is just RGB in base-16, packed into a six-character string for terse CSS and Figma copy-paste. HSL, HSV, and HWB are designer-cognitive spaces — cylindrical reshapes of RGB that let you rotate hue, lighten, or darken with intuitive sliders. HSL was published in 1978 alongside HSV by Alvy Ray Smith; HWB was added in 1996 as a cleaner mental model (Hue + amount of White + amount of Black). CMYK is a print-process abstraction — a subtractive ink stack (Cyan, Magenta, Yellow, Key=black) that models how ink absorbs light on paper rather than how a screen emits it. OKLCH and OKLAB are perceptual spaces — they're designed so that equal numeric distance corresponds to equal perceived distance, which makes them indispensable for design-system ramps and accessibility math. Named colors are CSS legacy: the 148 SVG/CSS3 names like `tomato`, `rebeccapurple`, and `slategray` that ship with every browser.
For more than twenty years sRGB was "good enough" — a 1996 IEC standard built around the phosphor primaries of the CRT monitors of the day. It quietly defined the upper bound of what a web color could mean. Then wide-gamut displays broke the assumption. Apple's Display P3 covers roughly 50% more of the visible spectrum than sRGB and now ships in every iPhone, iPad, and MacBook from 2017 onward. Rec.2020 covers even more and is the broadcast standard for HDR TV. HSL embedded sRGB's gamma quirks deep in its definition, which is why an HSL ramp looks visually uneven on a wide-gamut display — a green at L=50% looks brighter than a blue at L=50%, because HSL's L is geometric, not perceptual. In 2020 Björn Ottosson published OKLAB, a perceptually-uniform color space derived from CIE-LAB with corrected lightness response and cleaner behavior at high saturation. OKLCH is its polar form (Lightness / Chroma / Hue), the same shape as HSL but with the perceptual math fixed. CSS Color 4 added `oklch()` and `oklab()` syntax in 2022; Chrome 111 shipped support in March 2023, Safari 15.4 already had it as of March 2022, and Firefox 113 landed in May 2023. Tailwind v4, released in 2025, made OKLCH its default color token format; shadcn/ui followed shortly after. This tool reflects that shift by making OKLCH the internal source of truth — every conversion routes through OKLCH, so a HEX → RGB → OKLAB → HEX round-trip never accumulates float drift, and editing the L channel of OKLCH directly updates every other field exactly.
Which space you reach for depends entirely on what you're doing. **HEX** is the right call for web embedding, copy-paste between design tools and code, and anywhere terse identifiers matter — `#3b82f6` fits in a CSS variable comfortably and most front-end developers can read it on sight. The dedicated hex to RGB converter handles the single most common direction one-step; the reverse RGB to hex converter covers the case where you have separate channel integers from a designer or image-pixel-math pipeline. **RGB** is for direct hardware addressing — anywhere you need 0-255 integers (canvas APIs, image manipulation, hardware LED strips, OpenGL color attributes). **HSL** is the legacy designer-cognitive space — rotate hue, lighten, darken — and still useful when you need a quick CSS color tweak in a project that hasn't migrated to OKLCH. The single-direction hex to HSL converter is the right shortcut when that's all you need. **HSV and HWB** are designer color-picker spaces. HSV (Hue, Saturation, Value) matches the saturation-value square most picker UIs draw, so it's what Photoshop, Figma, and Sketch report when you click the eyedropper. HWB is the cleaner mental model — pick a pure hue, then add white to lighten or black to darken — and CSS Color 4 added native `hwb()` support across all evergreen browsers. **CMYK** is for print preparation. A blunt disclaimer: our CMYK output is a naive sRGB-based approximation using the standard `K = 1 - max(R,G,B); C = (1-R-K)/(1-K)` formula. Real print accuracy requires ICC profile conversion against the specific press, ink, and paper — typically US Web Coated SWOP v2 or Fogra39 — which can shift channels by 5-15%. Treat our CMYK as a starting estimate, not a deliverable. The single-direction hex to CMYK converter applies the same formula with the same caveat. **OKLCH** is the default choice for new code in 2025 and forward — modern design systems, accessibility-aware palette generation, anywhere perceptual uniformity matters. The single-direction hex to OKLCH converter exists for quick legacy-palette migration. **OKLAB** is the rectangular cousin used for palette math: mid-points between two colors, distance calculations, color-blindness simulation matrices, and other operations that need linear-axis arithmetic. **Named colors** are for documentation, code comments, mocks, and prose — the 148 CSS named colors are a fixed dictionary, and the tool finds the closest named color for any input via ΔE distance in OKLAB.
The conversion graph at the heart of all this is well-defined and surprisingly clean. sRGB and linear-sRGB are related by a piecewise gamma curve specified in W3C CSS Color 4 §11.2 (roughly a 2.4 exponent with a small linear segment near zero). Linear-sRGB and CIE XYZ D65 are related by a fixed 3×3 matrix from CSS Color 4 §15.1. XYZ D65 and OKLAB are related by two matrices and a cube-root step (the LMS cone-response stage, per Ottosson 2020). OKLAB and OKLCH are related by a Cartesian-to-polar transform — `C = sqrt(a² + b²); H = atan2(b, a)`. HEX is just sRGB serialized as `#RRGGBB` base-16. RGB ↔ HSL, RGB ↔ HSV, RGB ↔ HWB are direct geometric transforms within sRGB, defined in CSS Color 4 §5-7. CMYK is the naive sRGB-based formula above. The whole pipeline is a directed graph rooted at OKLCH internally; every other format is computed from it on every keystroke.
Beyond the core conversion, this tool ships features the legacy generation didn't. **Display P3 and Rec.2020 gamut detection** — three badges flag whether the current color falls inside each space's reproducible range, with a one-click **Snap to sRGB** button that uses binary chroma reduction (per CSS Color 4's informative algorithm) to shrink the color until it fits. **WCAG 2 + APCA Lc dual contrast badges** — both metrics displayed in one row so you can pass the regulatory standard today and sanity-check with the forward-looking perceptual metric. **8 color-blindness simulations** — protanopia, deuteranopia, and tritanopia via the Brettel-Viénot-Mollon 1997 dichromacy matrices; protanomaly, deuteranomaly, and tritanomaly via Machado-Oliveira-Fernandes 2009 anomalous-trichromacy matrices at severity 0.66; achromatopsia and partial achromatomaly via rec601 luminance weights. **OKLCH-uniform palette generation** — tints, shades, tones, and harmonies built by stepping the L channel in equal increments while holding C and H fixed (the same construction as Tailwind v4's default palette). **CSS / Tailwind v4 / SwiftUI / Compose / Flutter code snippets** — paste-ready output for the five platforms most cross-team teams target. **EyeDropper API integration** on Chromium browsers (Chrome, Edge, Brave, Opera) for picking colors anywhere on screen including outside the browser. **URL hash state** — the current color encodes into the URL as `#hex=...` or `#oklch=...` so you can share a live link to the exact color with one copy.
Everything in this tool runs locally in your browser. Your color values are never uploaded, never logged, never analyzed, never persisted on a server. Zero network requests as you type — open the browser DevTools Network tab and watch: typing in any field triggers no traffic at all. This makes the tool safe for unannounced brand palettes, internal design-token systems, draft mockups, and any other confidential color work. No cookies record what you paste; no analytics fire on color changes. The same posture extends to the URL hash: the `#hex=...` fragment lives only in your address bar and is never transmitted to the server (browsers don't include the fragment in HTTP requests), so even a shared link doesn't leak the color to any third party other than the recipient you sent it to. For teams handling pre-launch brand work, embargoed campaigns, or client palettes under NDA, this matters more than the convenience headline suggests. For a deeper dive into why OKLCH became the design-system standard in 2024–2026, read our companion guide: OKLCH color space explained — why Tailwind v4 adopted it.
// sRGB → linear → XYZ D65 → OKLAB → OKLCH
// References: W3C CSS Color 4 §11-15, Ottosson 2020 (https://bottosson.github.io/posts/oklab/)
// Worked example: #3b82f6 (Tailwind blue-500)
const srgb = [0x3b, 0x82, 0xf6].map(v => v / 255); // [0.231, 0.510, 0.965]
const toLinear = (v) => v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
const lin = srgb.map(toLinear); // gamma-decoded linear-sRGB
// linear-sRGB → XYZ D65 (CSS Color 4 §15.1 matrix)
const [lr, lg, lb] = lin;
const x = 0.4124564 * lr + 0.3575761 * lg + 0.1804375 * lb;
const y = 0.2126729 * lr + 0.7151522 * lg + 0.0721750 * lb;
const z = 0.0193339 * lr + 0.1191920 * lg + 0.9503041 * lb;
// XYZ D65 → LMS (Ottosson 2020 matrix), cube-root, → OKLAB
const l_ = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
const m_ = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
const s_ = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.6338517070 * z);
const L = 0.2104542553 * l_ + 0.7936177850 * m_ - 0.0040720468 * s_;
const a = 1.9779984951 * l_ - 2.4285922050 * m_ + 0.4505937099 * s_;
const b = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.8086757660 * s_;
// OKLAB → OKLCH (Cartesian to polar)
const C = Math.sqrt(a * a + b * b);
const H = (Math.atan2(b, a) * 180 / Math.PI + 360) % 360;
console.log(`oklch(${L.toFixed(3)} ${C.toFixed(3)} ${H.toFixed(1)})`);
// → oklch(0.629 0.193 263.4) Key Features
9 Simultaneously Editable Color Spaces
Every format — HEX, RGB, HSL, HSV, HWB, CMYK, OKLCH, OKLAB, and CSS named color — is a directly editable field, not a one-direction dropdown. Type an `oklch()` value and HEX, RGB, HSL all update; paste a hex from Figma and OKLCH updates with the matching perceptual coordinates. The cursor in the field you're editing stays put — only the other eight fields re-render on each keystroke, so editing flows naturally.
OKLCH Source-of-Truth — Bit-Perfect Round-Trips
The internal canonical representation is OKLCH, the perceptually-uniform polar form of OKLAB (Ottosson 2020). Every other format is derived from it on every keystroke. This means HEX → RGB → HSL → OKLAB → HEX round-trips without float drift — the original hex comes back unchanged. Legacy converters that route conversions through HSL or sRGB accumulate per-step rounding error; this tool doesn't.
Display P3 + Rec.2020 Gamut Warnings
Three live badges (sRGB, Display P3, Rec.2020) show whether the current color falls inside each space's reproducible range. Useful when you're working in OKLCH and want to know which displays will render the value accurately — many Tailwind v4 OKLCH colors exceed sRGB but fit P3, which most Apple devices since 2017 can render. The Snap to sRGB button uses CSS Color 4's binary chroma-reduction algorithm to shrink the color until it fits.
WCAG 2 + APCA Contrast In One Row
Contrast against both white and black is shown using two metrics side by side: the WCAG 2.1 ratio (4.5:1 = AA body text, 7:1 = AAA) for regulatory compliance today, and the APCA Lc score (the forward-looking WCAG 3 perceptual contrast algorithm). APCA is polarity-sensitive (light-on-dark weighs differently than dark-on-light), which WCAG 2's symmetric formula gets wrong. Use both: WCAG for audits, APCA for real readability.
Color-Blindness Simulation Across 8 Deficiency Types
Live previews for the three dichromacies (protanopia, deuteranopia, tritanopia) via Brettel-Viénot-Mollon 1997 matrices, the three anomalous trichromacies (protanomaly, deuteranomaly, tritanomaly) via Machado-Oliveira-Fernandes 2009 matrices at severity 0.66, plus achromatopsia and achromatomaly via rec601 luminance weights. Covers roughly 8% of men and 0.5% of women — the populations your design needs to remain accessible to.
OKLCH-Uniform Tints, Shades, Tones, and Harmonies
Palette ramps are generated by stepping the L channel in equal OKLCH increments while holding Chroma and Hue fixed — the same construction Tailwind v4 uses. The result is perceptually-even: the visual gap between the 400 and 500 stops looks identical to the gap between 500 and 600, which an HSL ramp can't guarantee. Harmonies (complement, triad, tetrad, split-complement) rotate Hue by exact angles and preserve L+C.
Copy as CSS / Tailwind v4 / SwiftUI / Compose / Flutter
One-click code generation for the five platforms most cross-team teams ship to: CSS custom property (`--color-brand: oklch(0.629 0.193 263.4)`), Tailwind v4 `@theme` token, SwiftUI `Color(red:green:blue:)` literal, Jetpack Compose `Color(0xFF3B82F6)` constant, Flutter `Color(0xFF3B82F6)`. The exact syntax each platform expects, ready to paste into a brand stylesheet, an iOS asset catalog, or an Android theme.
Hand-Implemented OKLCH Picker (Zero Dependencies)
The SL square + hue slider + alpha slider are written in plain canvas + JavaScript with no external picker library. The OKLCH gradient on the hue slider is computed from real OKLCH math, not approximated with HSL, so dragging the slider produces perceptually-uniform hue rotation. Bundle weight stays under 10 KB for the entire interactive layer; first paint is fast even on cold loads.
100% In-Browser — No Upload, No Tracking
All conversion math, palette generation, contrast scoring, and gamut detection runs locally in your browser. Your color values are never transmitted, never stored on a server, never logged, never analyzed. Zero network requests as you type — verify in DevTools. Safe for unannounced brand palettes, internal design tokens, draft mockups, and any other confidential color work.
Color Converter Alternatives Compared
ColorHexa
browser toolA long-time competitor with deep per-color information pages — generates a full SEO page per hex with conversions, palettes, harmonies, and gradients. UI is dated (early-2010s aesthetic), no OKLCH support, no APCA contrast, no wide-gamut handling. Strong for SEO discovery of a specific color ("#FF5733" the search query); weaker for active design work where unified-field UX matters.
RapidTables
browser toolWide selection of single-direction converters (HEX to RGB, RGB to HEX, HEX to HSL, etc.) plus other unit tools. Each conversion is a separate page with a one-way form — no live unified-fields experience. No OKLCH support, no gamut warnings, no contrast checking. Useful for one-off quick conversions when you arrive from a Google search; this tool is faster for any workflow with more than one conversion.
HTMLColorCodes
browser toolStrong color-picker and palette-generator with a clean UI. The picker UX is good for visual exploration. Converter side is basic — HEX, RGB, HSL, HSV, CMYK only; no OKLCH, no OKLAB, no gamut detection. Best when you need to explore variations of a color visually; this tool wins when you need modern color spaces or precise conversion math.
OKLCH.com
browser toolBeautifully-built OKLCH-focused tool by Andrey Sitnik (author of the postcss-oklab-function polyfill). Best-in-class for OKLCH-specific exploration with a wide-gamut-aware picker and palette generation. Doesn't cover HEX/RGB/HSL/CMYK conversion as primary outputs — focused on OKLCH alone. Reach for OKLCH.com when you're doing pure OKLCH design work; reach for this tool when you need cross-space conversion.
ConvertingColors
browser toolCovers many color spaces (HEX, RGB, HSL, HSV, CMYK, XYZ, CIELAB, and several more) with a per-color SEO-content-page model similar to ColorHexa. Lacks modern OKLCH support, no APCA contrast, no wide-gamut handling, and the auto-generated content pages feel content-farm-ish. Good for spelunking individual color metadata; this tool is faster for active design and accessibility work.
IT-Tools
open-source browser toolClean self-hostable Vue 3 collection of dev tools, with a color converter among many other utilities. UX is consistent across the whole suite. The color converter covers HEX, RGB, HSL, HSV, CMYK; no OKLCH, no gamut warnings, no contrast checking, no color-blindness simulation. Worth running locally if you want a self-hosted multi-tool collection; this tool is the dedicated, deeper color-only option.
W3Schools Color Converter
browser toolBasic HEX/RGB/HSL toggle on a beginner-friendly page, ubiquitous in search results for color-converter queries. No OKLCH, no advanced features. Useful as a teaching reference next to W3Schools' explainer content. This tool wins on every other axis: more spaces, perceptual math, gamut + contrast + CVD features, modern Tailwind v4 / SwiftUI / Compose / Flutter code export.
Color Conversion Examples
Tailwind v4 brand color → OKLCH
#3b82f6
OKLCH output: `oklch(0.629 0.193 263.4)`. Drop it straight into a Tailwind v4 `@theme` block as `--color-brand-500: oklch(0.629 0.193 263.4);` and the rest of your ramp lines up perceptually. Tailwind v4 standardized on OKLCH for its default palette in 2024 specifically because the L channel keeps lightness consistent across hues — green-500 and blue-500 look equally bright, which HSL/RGB ramps can't guarantee. The hex is preserved verbatim if you also need a fallback for older browsers.
Web hex → SwiftUI Color literal
#FF5733
SwiftUI output (under Copy as code → SwiftUI): `Color(red: 255/255, green: 87/255, blue: 51/255)`. The classic iOS / macOS workflow: a designer drops a hex into Figma's brand panel, you paste it here, and copy the SwiftUI literal into a `View`. The expression form (with the explicit `/255` divisions) is intentional — it survives a code review better than the opaque `Color(red: 1.0, green: 0.341, blue: 0.2)` because the original brand hex is still visible in the source.
Designer palette swatch → CMYK approximation for print
#FF6347
CMYK output: roughly `cmyk(0%, 61%, 72%, 0%)`. This is a naive sRGB → CMYK conversion using the standard `K = 1 − max(R,G,B); C = (1−R−K)/(1−K)` formula — useful as a quick starting estimate for a print quote, but not a substitute for the real conversion. A print shop will run the file through an ICC profile (typically US Web Coated SWOP v2 or Fogra39) tuned to the exact press, ink, and paper, which can shift channels by 5-15%. Treat this number as a sanity check, not a deliverable.
OKLCH wide-gamut color → sRGB fallback
oklch(0.7 0.25 30)
The gamut row immediately flags this color as **outside sRGB** (Display P3 covers it, Rec.2020 covers it). On a standard monitor it renders as a desaturated approximation; on a P3-capable display (most laptops shipped after 2017) it renders saturated. Click **Snap to sRGB** to reduce chroma until the color fits the sRGB cube, then copy the resulting hex (around `#ef6b50`) as the fallback. The OKLCH source-of-truth lets you keep the wide-gamut value in your design token and ship the snapped hex as the `@supports not (color: oklch(...))` fallback.
Verify WCAG contrast for body text
#767676
Against white (`#ffffff`) the WCAG 2.1 contrast ratio comes back at about **4.54:1** — just over the 4.5:1 AA threshold for normal body text. Drop one digit to `#777777` and the ratio falls to 4.48:1, which fails AA. The APCA Lc value is surfaced alongside as a forward-looking metric (WCAG 3 draft) — APCA scores this pair at around `Lc 60`, slightly below APCA's recommended `Lc 75` for body text. Use both: WCAG to pass audits today, APCA to make sure the result actually looks readable.
Discover the CSS named color closest to a brand hex
#FF6347
The **Named** field returns `tomato (exact)` because the CSS spec defines `tomato` as literally `#FF6347` — one of 148 named colors that ship with every browser. Try a near-miss like `#FF6348` and the field returns `tomato (nearest, ΔE 0.02)`, telling you the closest named color and how far off it is using CIE ΔE (Delta-E in OKLAB space). Useful when you're writing copy or comments and want a human-readable color name instead of a hex code.
Convert an old HSL value to modern OKLCH
hsl(220 70% 50%)
OKLCH output: approximately `oklch(0.5 0.187 263)`. HSL's L=50% is **not** perceptually 50% — blue at L=50% looks much darker than yellow at L=50% because HSL is a cylindrical reshape of sRGB, not a uniform space. OKLCH's L=0.5 actually corresponds to the mid-gray luminance your eye perceives. When you migrate a HSL design system to OKLCH, expect the L values to drift (blues go up, yellows go down) — that's the system correcting itself, not a bug.
Find a palette of 5 tints and 5 shades from a brand color
#3b82f6
The **Tints / Shades / Tones / Harmonies** section generates 5 lighter and 5 darker variants by stepping the OKLCH L channel in equal increments while holding C and H fixed. The result is a perceptually-even ramp — the gap between `500` and `600` looks the same as the gap between `600` and `700`, which is what a design system needs. Click any swatch to load it as the active color, then copy its hex/OKLCH. Same construction as Tailwind v4's default palette generator.
How to Use the Color Converter
- 1
Paste or type any color in any format
Every one of the 9 format fields (HEX, RGB, HSL, HSV, HWB, CMYK, OKLCH, OKLAB, Named) is directly editable — there is no "Convert" button to click. Paste a hex from Figma, type an `oklch()` value from a Tailwind config, drop in a `hsl()` from an old stylesheet, or even type a CSS named color like `tomato`. The tool parses incrementally as you type, so a half-typed value won't blow away the others until you commit a valid format. Invalid input gets a quiet inline error; valid input updates the entire grid.
- 2
All 9 formats update instantly
The internal source of truth is OKLCH (perceptually uniform, gamut-unbounded), and every other format is derived from it on every keystroke. The field you're currently typing in keeps its cursor position untouched — only the *other* eight fields re-render. This means you can edit the L channel of OKLCH directly and watch hex, RGB, HSL, and CMYK all shift in real time without losing your cursor. The conversion math runs entirely in JavaScript using the same OKLAB primitives that ship in modern browsers.
- 3
Use the picker for visual exploration
Below the format grid is a saturation-lightness square (drag anywhere to set S+L for the current hue), a hue slider (drag to rotate around the color wheel), and an alpha slider (drag to set transparency). On Chromium-based browsers (Chrome, Edge, Brave) the **Eyedropper** button activates the native `EyeDropper` API — click anywhere on screen, including outside the browser window, to sample that pixel's color. Safari and Firefox don't yet ship the API, so the button is hidden in those browsers and the SL square + hue slider remain the primary picker.
- 4
Check gamut and contrast at a glance
Three gamut badges (**sRGB**, **Display P3**, **Rec.2020**) show whether the current color falls inside each space's reproducible range — useful when you're working in OKLCH and want to know which displays will render the value accurately. The contrast row shows the WCAG 2.1 ratio against both white and black, plus the APCA Lc score (forward-looking WCAG 3 metric). Pass / fail badges (AA, AAA) appear inline. If a color is out of sRGB gamut, a **Snap to sRGB** button shrinks the chroma until it fits.
- 5
Copy in your platform's native syntax
Each of the 9 format fields has its own **Copy** button — one click, the value lands on your clipboard, the label briefly switches to "Copied!" so you know. Below the picker the **Copy as code** section generates ready-to-paste snippets for five platforms: CSS custom property, Tailwind v4 `@theme` token, SwiftUI `Color(red:green:blue:)` literal, Jetpack Compose `Color(0xFF...)` constant, and Flutter `Color(0xFF...)`. The URL hash (`#hex=...` or `#oklch=...`) also updates so you can share a live link to the exact color.
Common Color-Conversion Mistakes
Confusing HSL With OKLCH
Both spaces share the same Hue / Lightness / (Saturation or Chroma) cylindrical shape, which makes them look interchangeable on paper. They aren't. HSL's L is geometric — derived from RGB by averaging max and min channel values — and embeds sRGB's gamma curve. OKLCH's L is perceptual, anchored to the OKLAB model. An HSL ramp at uniform L looks visibly uneven across hues; an OKLCH ramp at uniform L stays even. Don't substitute one for the other in a design-system migration without re-tuning.
Assume an HSL palette is perceptually uniform: hsl(220 50% 30%) → hsl(220 50% 60%) → hsl(220 50% 90%) On screen these look unevenly spaced.
Use OKLCH for perceptually-uniform ramps: oklch(0.30 0.10 220) → oklch(0.60 0.10 220) → oklch(0.90 0.10 220) On screen these look evenly spaced.
Trusting Naive CMYK for Print
The CMYK output here comes from the standard `K = 1 - max(R,G,B)` textbook formula applied to sRGB. It's a useful ballpark but not a substitute for the real conversion. Print shops run files through an ICC profile (US Web Coated SWOP v2, Fogra39, Japan Color 2011, etc.) tuned to the specific press, ink, and paper. ICC-converted CMYK can differ from the naive formula by 5-15% per channel. Send the original sRGB hex to the printer and let them do the proper conversion.
Send our CMYK output directly to a press: hex #FF6347 → cmyk(0%, 61%, 72%, 0%) Printed result may look muddy or oversaturated.
Send the original hex to the print provider: hex #FF6347 → let printer ICC-convert against their press Printed result matches the screen color much more closely.
Reading APCA Lc as a WCAG-2-Compatible Number
APCA Lc and WCAG 2 ratios are different scales measuring different things. WCAG 2 gives a ratio from 1:1 (no contrast) to 21:1 (max contrast), with 4.5:1 the legal AA floor for body text. APCA gives Lc from 0 to ±108 with sign indicating polarity (positive for dark text on light bg, negative for light text on dark bg). Lc 60 doesn't map to WCAG 4.5:1; the relationship is non-linear and direction-dependent. Use both metrics, side by side, not one as a translation of the other.
Pretend Lc 60 = WCAG 4.5:1: APCA Lc 60 → "this passes AA" WCAG 2 ratio for the same pair might be 3.8:1 (fails AA).
Check both metrics independently: WCAG 2 ratio ≥ 4.5:1 for AA body text compliance, AND APCA |Lc| ≥ 75 for real-world readability. Both must pass, not one substituting for the other.
Using HSL for Design-System Shades
Generating a 50/100/200/.../900 ramp by stepping HSL's L channel produces a visually uneven ramp because HSL's L isn't perceptual. The dark stops look too dark, the light stops look too light, and the middle stops compress. Designers fix this by hand-tuning each stop, a multi-hour exercise per brand color. OKLCH solves the problem by construction — equal L steps look equal — so the ramp is even on the first try.
Step HSL L for shades: hsl(220 50% 30%) / hsl(220 50% 60%) / hsl(220 50% 90%) 90% looks washed out; 30% looks much darker than the gap to 60%.
Step OKLCH L for shades: oklch(0.30 0.10 220) / oklch(0.60 0.10 220) / oklch(0.90 0.10 220) Each step looks like the same visual gap.
Forgetting Alpha When Copying HEX
8-digit hex (`#RRGGBBAA`) and 4-digit shorthand (`#RGBA`) encode alpha transparency in the last pair. CSS supports both; older parsers (including some legacy CSS preprocessors and design tools pre-2018) only understand 6-digit hex and silently truncate the alpha. The result: a color you expected to be 50% transparent renders as fully opaque. Always verify the target syntax accepts 8-digit hex before copying alpha-bearing values; for legacy targets, fall back to `rgba()`.
Copy 8-digit hex into a legacy parser: #FF573380 → parser truncates → #FF5733 (no alpha) The 50% transparency is silently lost.
Verify target supports 8-digit hex, or use rgba(): for modern CSS: #FF573380 (8-digit hex) for legacy support: rgba(255, 87, 51, 0.5) (always supported) Explicit alpha syntax avoids silent truncation.
Snapping to sRGB Without Considering Display P3
Snap to sRGB is a useful safety net for legacy contexts, but applying it indiscriminately defeats the wide-gamut display you may be designing for. Most Apple devices from 2017 onward render Display P3 natively; many modern Android devices and laptop screens do too. A wide-gamut OKLCH color that exceeds sRGB but fits P3 looks dramatically more saturated on P3 hardware than the snapped sRGB approximation. Check the P3 gamut badge first; only snap when targeting sRGB-only legacy contexts.
Snap every OKLCH color to sRGB by default: oklch(0.7 0.25 30) → snap → oklch(0.7 0.18 30) P3 displays lose 30%+ saturation for no reason.
Check Display P3 badge first: if fits-P3: keep the wide-gamut value, add sRGB fallback via @supports if exceeds P3: then snap to sRGB Let the wide-gamut hardware do its job.
Who Uses This Tool
- Frontend Devs Migrating to Tailwind v4 OKLCH Tokens
- Tailwind v4 standardized on OKLCH for its default palette in 2024. Migrating an old HSL- or hex-based design system means converting hundreds of brand colors to OKLCH. Paste each hex, copy the OKLCH output, drop into the `@theme` block. The live gamut badges flag any colors that exceed sRGB so you can decide whether to keep the wider-gamut value for Display P3 displays.
- Designers Translating Figma Colors to iOS / Android
- Figma exports hex by default, but iOS wants SwiftUI `Color(red:green:blue:)` literals and Android wants Jetpack Compose `Color(0xFF...)` constants. Paste the Figma hex once, copy the SwiftUI snippet for the iOS engineer and the Compose snippet for the Android engineer — both already in the exact syntax each platform expects, with the original hex preserved in a comment for traceability.
- Designers Prepping Print Proofs (CMYK Approximation)
- When a brand color has to appear on a printed business card, the CMYK approximation gives a quick estimate to share with the print shop before the proper ICC conversion. Paste the brand hex, copy the CMYK percentages, send to the printer for a quick price quote — then defer to the printer's ICC-profile-aware conversion for the final color match against the specific press.
- Accessibility Engineers Verifying WCAG and APCA
- WCAG 2.1 is the regulatory standard (ADA, EAA, Section 508) today; APCA Lc is the proposed WCAG 3 successor. Both metrics shown side by side means a designer can verify a body-text color hits 4.5:1 WCAG against white, then sanity-check that it also clears APCA Lc 75, in one screen — without bouncing between two separate calculators.
- Educators Teaching Color-Space Concepts
- The simultaneous nine-field view makes color-space relationships visible. Type an OKLCH value, watch HSL drift because L means different things in each space. Drag the hue slider and watch hex, RGB, and CMYK all update. Show the gamut badges turning red as you push chroma past sRGB. The tool is its own classroom demo for a college-level graphics or HCI course.
- Brand Managers Finding the Closest CSS Named Color
- When the marketing copy says "a tomato-colored accent" but the actual brand hex is `#FF6347`, the Named field returns `tomato (exact)` because that's literally what `tomato` resolves to in the CSS spec. For near-miss hexes, the field returns the closest named color with the ΔE distance in OKLAB — useful for documentation, prose, and casual color-naming.
- Web Devs Converting Legacy HEX Palettes to OKLCH
- An older site might have a 50-color brand palette defined in CSS custom properties as hex codes. Modernizing to OKLCH lets the brand team express the same ramps in a perceptually-uniform space. Paste each hex, copy the OKLCH output, swap into the variable definitions. The Tints/Shades panel below verifies the resulting ramp is visually even before shipping.
- Open-Source Maintainers Documenting Design Tokens
- Design-token documentation usually needs to show the same color in multiple syntaxes — hex for the CSS code block, OKLCH for the spec table, the named color for prose mentions. The simultaneous-field view lets a maintainer copy each in one pass instead of re-running three separate conversions. The shareable URL hash also lets contributors link to the exact color under discussion in a GitHub issue.
Color Conversion Math & Algorithms
- OKLCH as Internal Source-of-Truth
- The tool holds the canonical color value as an OKLCH triple internally. Every editable field derives its display value from that triple on every keystroke; every user edit updates the triple first, then triggers re-render of the other eight fields. This eliminates the per-step float drift that plagues converters routing through HSL or sRGB as their pivot. The choice of OKLCH over OKLAB is deliberate — the polar form preserves Hue as a stable axis, so dragging the hue slider doesn't accidentally cross-fade through gray. Per Björn Ottosson's 2020 paper, OKLAB's perceptual uniformity is the strongest argument for treating it as the lingua franca of modern color math.
- Matrix Sources (W3C CSS Color 4 + Ottosson 2020)
- Every conversion matrix in the codebase is cited to its primary source. The sRGB ↔ linear-sRGB piecewise gamma function is W3C CSS Color 4 §11.2 (`v <= 0.04045 ? v/12.92 : ((v+0.055)/1.055)^2.4`). The linear-sRGB ↔ CIE XYZ D65 3×3 matrix is CSS Color 4 §15.1. The XYZ D65 ↔ LMS matrix and the OKLAB cube-root step are from Ottosson's `https://bottosson.github.io/posts/oklab/` reference implementation, exactly as published. No matrices are recomputed or re-derived — copying them verbatim keeps the output identical to the spec's reference vectors.
- Naive CMYK Formula and the ICC Caveat
- Our CMYK output uses the standard textbook formula: `K = 1 - max(R, G, B); C = (1-R-K)/(1-K); M = (1-G-K)/(1-K); Y = (1-B-K)/(1-K)` operating on normalized sRGB values. This is a deliberate approximation. Real print accuracy requires an ICC profile conversion against the specific press, ink (e.g., US Web Coated SWOP v2, Fogra39, Japan Color 2011), and paper, which can shift channels by 5-15%. We surface the CMYK field with a visible disclaimer so users don't ship our values directly to a press. Treat the output as a sanity check for quotes, not a deliverable.
- Gamut Detection via Channel-Range Check
- A color is considered in-gamut for a target space (sRGB, Display P3, Rec.2020) if every channel falls inside `[-ε, 1 + ε]` after conversion to that space's primaries, where `ε = 1e-7` to absorb float-precision noise around boundaries. The gamut badge for each space turns red when any channel exceeds the range. This catches the common case — a wide-gamut OKLCH color like `oklch(0.7 0.4 30)` reports out-of-sRGB but in-P3, telling you which displays will render it accurately. The check runs on every keystroke.
- Chroma-Reduction Snap Algorithm
- Snap to sRGB uses binary search on the Chroma axis: hold L and H fixed at the current values, search C ∈ [0, currentC] for the largest C whose sRGB conversion stays in-gamut. The search runs at most 30 iterations (precision ~10⁻⁹), which is more than enough for visual accuracy. This matches the informative gamut-mapping algorithm described in CSS Color 4 §13 — preserving lightness and hue while reducing only chroma keeps the snapped color recognizably the same hue family. We don't clip RGB channels directly because that distorts hue noticeably (especially in blues).
- Brettel + Machado CVD Matrices
- Color-blindness simulation uses two published matrix families. The three dichromacies — protanopia, deuteranopia, tritanopia — use Brettel-Viénot-Mollon 1997 matrices operating in linear-RGB (gamma-decode first, apply matrix, gamma-encode back). The three anomalous trichromacies — protanomaly, deuteranomaly, tritanomaly — use Machado-Oliveira-Fernandes 2009 matrices at severity 0.66, which corresponds to a typical anomalous-trichromacy patient. Achromatopsia and partial achromatomaly use rec601 luminance weights (`0.299R + 0.587G + 0.114B`) for a grayscale projection. All eight simulations render on every color change.
- WCAG 2 vs APCA: Which to Use When
- WCAG 2.x (current standard) computes a symmetric contrast ratio from relative luminance: `(L1 + 0.05) / (L2 + 0.05)`, target 4.5:1 for normal body text and 7:1 for AAA. It's the legal compliance floor for accessibility audits in 2026. APCA (Accessible Perceptual Contrast Algorithm) is the proposed WCAG 3 successor — polarity-sensitive (light-on-dark scores differently from dark-on-light), better correlated with human-perceived readability, target `|Lc| ≥ 75` for body text. Both metrics shown in one row lets a designer hit WCAG 2 for compliance and APCA for real-world readability without bouncing between two separate calculators.
Best Practices for Color Conversion
- Prefer OKLCH for Design-System Tokens; HEX for Legacy
- For any new design system shipping in 2025 or later, define brand colors and palette ramps in OKLCH. The L axis gives perceptually-even ramps automatically; the Chroma axis can address wide-gamut colors that hex can't encode. Keep a hex fallback for older browsers via `@supports not (color: oklch(0 0 0))` or build-time PostCSS, but make OKLCH the canonical value in your token store. Legacy systems with thousands of existing hex variables can stay hex until a planned migration — don't churn for its own sake.
- Treat CMYK Output as Approximation, Confirm With Print Provider
- The CMYK numbers this tool surfaces are a naive sRGB-based formula, not an ICC-profile conversion. Use them for ballpark quotes and internal comps. Before any real print run, send the original hex (not the CMYK approximation) to the print provider and let them run their own ICC conversion against the specific press, ink, and paper. The 5-15% channel shift from a proper conversion can easily turn a sharp red into a muddy orange if the approximation is shipped directly.
- Use APCA Lc for Forward-Looking Accessibility
- WCAG 2.x will continue to be the regulatory floor for several more years, but APCA is the direction the standard is moving. For new designs, hit `|Lc| ≥ 75` for body text and `|Lc| ≥ 60` for large text alongside the WCAG 2.1 floors. APCA catches readability problems that WCAG 2's symmetric ratio misses — particularly thin-stroke text on bright backgrounds, where the WCAG ratio looks fine but the text actually disappears at normal reading distance.
- Run Wide-Gamut Colors Through Display P3 Gamut Check
- If you're targeting modern Apple hardware (iPhone, iPad, MacBook from 2017+) or shipping HDR-aware content, define brand colors in OKLCH and use the Display P3 badge to verify they fit P3 even if they exceed sRGB. The wider-gamut colors look noticeably more saturated on P3 displays and degrade gracefully via browser-applied chroma compression on sRGB-only screens. Don't pre-snap to sRGB unless you know your entire audience is on legacy displays.
- Pick Perceptually Uniform Shades via OKLCH Tones
- When generating a 50/100/200/.../900 ramp for a brand color, use the Tones panel: it steps L in equal increments while holding C and H fixed. The result is a perceptually-even ramp where the visual gap between 400 and 500 looks identical to the gap between 500 and 600. Hand-tuning HSL ramps for the same evenness is a multi-hour exercise per color; OKLCH gives it for free.
- Use the Eyedropper Sparingly for Cross-Tab Color Matching
- The EyeDropper API (Chromium-only as of 2026) lets you click anywhere on screen — including outside the browser — to sample that pixel's color. Useful for matching a color from a screenshot, a video frame, or another app's UI. Treat the result as a starting point, not the final value — screen rendering applies color management that may differ from the source file. For canonical brand colors, always get the hex from the design source (Figma, Sketch, the brand guidelines PDF) rather than eyedroppering a screenshot.
- Bookmark URLs With `#hex=...` for Shareable Palette Decisions
- The current color encodes into the URL hash as `#hex=...` or `#oklch=...` automatically. Copy the URL, paste into a Slack thread or a GitHub issue, and anyone who opens it lands on the exact same color. Useful for design-review threads where "the brand blue" needs to mean one specific OKLCH triple. The hash updates on every change, so the URL in your address bar is always the live current color — bookmark it to come back to a specific palette later.
Frequently Asked Questions
How do I convert a hex code to RGB?
Is hex the same as RGB?
How do you read a hex color code?
What is the formula for hex to RGB?
Why use hex instead of RGB?
Can hex codes have alpha / transparency?
How many colors can hex represent?
What is OKLCH color?
Is OKLCH better than HSL?
What browsers support oklch()?
Why use OKLCH in Tailwind v4?
Is OKLCH perceptually uniform?
How do you read an OKLCH value?
What is the difference between gamut and color space?
Why is my OKLCH color out of sRGB gamut?
Should I use WCAG 2 or APCA for contrast?
What is the difference between HSV and HWB?
Related Tools
View all tools →Number Base Converter — Binary, Hex, Decimal & Octal
Conversion Tools
Convert between binary, hex, decimal, octal and any base (2-36) instantly. Free, private — all processing in your browser.
Hex to CMYK Converter
Conversion Tools
Convert HEX colors to CMYK in your browser. Naive sRGB-based approximation for print previews. Free, no signup, your colors stay local.
Hex to HSL Converter
Conversion Tools
Convert any hex color to HSL in your browser — 3-digit, 6-digit, 8-digit alpha all supported. Free, instant, no signup, your colors never leave the page.
Hex to OKLCH Converter
Conversion Tools
Convert HEX to OKLCH for Tailwind v4 design tokens. Live perceptually-uniform output with Display P3 gamut warnings. Free, browser-only.
Hex to RGB Converter
Conversion Tools
Convert any hex color code to RGB in your browser — 3-digit, 6-digit, and 8-digit alpha hex all supported. Free, instant, no signup, your colors never leave the page.
Compress Images Online — JPEG, PNG & WebP
Conversion Tools
Compress JPEG, PNG, WebP & AVIF up to 80% smaller — in your browser, no upload. Batch 20 images, resize, compare before & after, download as ZIP. Free & private.