Back to guides

Color Converter|Design HEX tokens into CSS variables and hsl()

Six-digit #RRGGBB, native color picker, synced RGB and HSL sliders—copy HEX, RGB, HSL, or rgba(...,1) locally before you wire Figma handoff into CSS variables and Tailwind arbitrary values.

By WGinit · November 30, 2026 · 4 min read · 14 views

Handoff stuck on HEX while code wants hsl()

Figma Dev Mode dumps #3B82F6 tokens while your design system spec asks for --color-primary: hsl(...) or Tailwind bg-[#3B82F6] plus a darker dark: twin. Mental HSL math in a review meeting is how saturation percent signs end up in the wrong place.

Dark mode notes like “same hue, drop lightness eight points” need numbers on screen, not vibes. Without a shared HSL readout, three files drift in the same PR.

Email inline styles, Markdown callouts, and screenshot annotations also ship hex. When you pair assets with the Base64 data URI guide or compress under 200KB, CSS should cite the same RGB triple the converter shows.

This tool does not sample the desktop, replace APCA checks, or audit your entire token JSON—it converts known six-digit hex in sRGB channel math.

How Color Converter works

Open Color Converter. A large swatch previews the active color. The format list exposes HEX, RGB, HSL, RGBA strings with per-row copy buttons.

HEX must be # plus six hex digits (ColorConverter.tsx regex). Invalid strings raise invalidHex. A native color picker beside the text field writes a legal hex and refreshes RGB.

RGB sliders span 0–255 with numeric inputs. HSL sliders use H 0–360, S/L 0–100%. Editing either side runs rgbToHsl / hslToRgb so HEX stays authoritative.

RGBA copies as rgba(r,g,b,1)—alpha is fixed at 1 in the UI. Everything runs client-side.

Slider inputs clamp to their min/max in code, so dragging past 255 on RGB or 360 on hue cannot produce illegal channel values in the copy strings.

Wire JSON, Markdown, and image workflows

Theme JSON from design ops? Expand keys in JSON Formatter, paste #2563EB here, then paste RGB integers into tailwind.config extend.colors.

Preview documentation colors in Markdown Preview after you unify on either hex or rgb() from this page.

Flow (figure)

Design HEX to CSS variables and Tailwind

Order: paste handoff hex → validate six digits → copy HSL or RGB → write CSS variables.

Still washed out (figure)

P3 displays, sRGB, shorthand hex

Wide-gamut laptops can look punchier than sRGB external monitors—the math here is 8-bit sRGB, not a promise of pixel match to every Figma color profile.

#RGB shorthand is rejected; expand to six digits in handoff.

Limits

Six-digit hex only—no #RRGGBBAA input; alpha slider not provided.

No contrast checker, no CSS file ingest, no bulk token import.

Rounded HSL integers may differ by one from design-tool decimals.

Values stay in the browser; brand palettes are still confidential in screenshots.

FAQ

QInclude the hash?

AYes—the field and copied HEX keep the leading #.

QCan I set transparency?

AYou can copy rgba(...,1) but cannot drag alpha; set opacity in CSS or export from design tools.

QTailwind arbitrary values?

APaste copied #3B82F6 or HSL into bg-[...]. Tailwind accepts arbitrary color strings, but this converter only performs format conversion—check contrast and accessibility separately.

Worked example (step by step)

1. Handoff token brand/primary → #2563EB.

2. Paste into Color Converter; confirm no invalidHex.

3. Copy hsl(217, 92%, 53%) into :root { --color-primary: ... }.

4. Dark token #1D4ED8 gets its own paste and HSL under prefers-color-scheme: dark.

5. Set Tailwind extend.colors.brand.DEFAULT to #2563EB; arbitrary bg-[#2563EB] for one-offs.

6. Drop the snippet into Markdown Preview HTML and eyeball headings.

7. PR body lists old/new HEX and RGB so Storybook defaults do not drift.

Copy-paste reference

Copy HSL from Color Converter into design tokens — matches what the sliders show.

:root {
 --brand: hsl(217, 92%, 60%);
 --brand-rgb: 59, 130, 246;
}
.button { background: var(--brand); }

Related tools

Related guides