Color Converter

Front-end developers pulling a HEX value out of a Figma file, SEO specialists matching a brand color inside structured data, and print coordinators translating screen colors into CMYK specs all hit the same wall. A value arrives in one format and the next system in the chain demands another, and hand-converting channel math under deadline is where off-by-one hex digits creep in.

This converter takes any HEX, rgb(), hsl(), hwb(), or cmyk() string and expands it into every other format at once, with a live swatch so you can see the color before you trust the numbers. A built-in contrast panel computes WCAG ratios between any two colors, and everything runs locally in the tab.

Preview
Converted formats
HEX#ff8800
RGBrgb(255 136 0)
HSLhsl(32 100% 50%)
HWBhwb(32 0% 0%)
CMYKcmyk(0% 46.7% 100% 0%)
WCAG contrast check
21:1 AA normal text AA large text AAA normal text

How the conversion math works

Every input is normalized to an RGB triple first, because RGB is the common denominator the other models decompose from. HEX parsing expands shorthand three and four digit forms by doubling each digit, then slices pairs into 0 to 255 channels. Functional notations are tokenized on commas, slashes, and whitespace, with the optional fourth component treated as alpha for rgb, hsl, and hwb but as the black channel for cmyk.

RGB to HSL finds the maximum and minimum channel to derive lightness as their average, saturation from the spread relative to that lightness, and hue from which channel dominates, scaled to 360 degrees. HWB reuses the same hue but reports the minimum channel as whiteness and one minus the maximum as blackness, following the CSS Color 4 rule that sums beyond 100 percent collapse to grey. CMYK divides each inverted channel by one minus the black key, with pure black short-circuiting to a key of 100.

The contrast panel applies the sRGB relative luminance formula, converting each channel through the piecewise gamma expansion before weighting green most heavily, then computes the lighter plus 0.05 over darker plus 0.05 ratio the WCAG specification defines. Rounding is deferred to display time so round-tripping a value through two formats stays within one channel unit of the original.

Before and after: brand HEX to every format

Input, a marketing HEX pulled from a brand sheet:

#ff8800

Output, all formats derived from that single value:

hex:  #ff8800
rgb:  rgb(255 136 0)
hsl:  hsl(32 100% 50%)
hwb:  hwb(32 0% 0%)
cmyk: cmyk(0% 46.7% 100% 0%)

contrast vs white: 2.39:1 (fails AA for body text)
contrast vs black: 8.77:1 (passes AAA)

Press the Brand blue sample above and the same expansion happens for #3b83f7, which converts to hsl(217 92.2% 60%) and cmyk(76.1% 47% 0% 3.1%), giving you a print spec and a CSS string from one paste.

Who converts colors with this tool

Developers

  • Translate design-token HEX values into HSL variables so a single lightness slider can generate an entire theme scale.
  • Convert legacy rgb(255, 136, 0) comma syntax into the modern space-separated form when modernizing a stylesheet.
  • Check that a brand color used as button text clears the 4.5:1 AA threshold against its background before shipping.

Production

  • Hand print vendors a CMYK specification generated from the live HEX in the brand portal instead of eyeballing a swatch book.
  • Standardize a color across a marketing site, email templates, and PDF one-sheets by copying the same converted strings into each system.
  • Verify accessibility ratios for every text-on-background pair in a design system during review, not after an audit finding.

Workflow

  • Paste a client HEX, copy the HSL row into a Tailwind theme file, and keep the CMYK row attached to the brand guide for the print vendor.
  • Batch through a palette by converting each swatch once and pasting the results into a shared spreadsheet the whole team reads.
  • Audit an existing stylesheet by converting suspicious values and checking which ones fail contrast against their actual usage.

Common mistakes when converting colors

  • Treating CMYK percentages as press-ready separations. The naive formulas here match the mathematical model but ignore ink limits, total area coverage, and the ICC profile of a specific press. Always have a commercial printer re-separate brand colors before a print run.
  • Forgetting that HWB sums are capped. Whiteness and blackness above a combined 100 percent discard the hue entirely, so dialing both sliders high yields grey rather than a tinted shade. If you want a pastel, keep blackness near zero and raise whiteness instead.
  • Judging contrast by eye. A color that looks fine on a calibrated designer monitor can fail AA on a washed-out laptop panel, which is exactly the device many users read email on. Copy both hex values into the contrast panel and trust the ratio over the swatch.
  • Dropping the hash or pasting extra whitespace. A value like " #ff8800 " with padding usually parses because the tool trims, but values copied from PDFs sometimes carry non-breaking spaces or a trailing semicolon that break strict parsers downstream. Trim to the bare value before committing it to code.

Best practices for color conversion workflows

  • 1.Store HEX as the source of truth in design tokens and derive HSL at build time, so a single edit propagates to every theme variant without manual re-entry.
  • 2.Convert and record the CMYK spec alongside the HEX in the brand guide, and note that it is a naive conversion the printer must profile before production.
  • 3.Run every text and background pair through the contrast panel and keep a screenshot of the passing ratio in the pull request, which shortens accessibility review later.
  • 4.Prefer space-separated rgb() and hsl() strings in modern CSS because the slash alpha syntax this tool emits also works in color-mix() and oklch() pipelines.

Frequently asked questions

How do I convert a HEX color to RGB and HSL?

Paste the HEX code into the input field, with or without the leading hash symbol, and the tool expands it into RGB, HSL, HWB, and CMYK values side by side. Short three-digit codes like #f80 are expanded to #ff8800 before conversion, so shorthand from CSS files works without editing. Each row shows both the raw components and a copy-ready CSS function string such as rgb(255 136 0) or hsl(32 100% 50%).

Which color format should I use in CSS?

HEX remains the most compact way to write an exact 24-bit color and is what most design tools export. HSL is easier for humans to adjust because the lightness slider behaves predictably when building palettes, and modern CSS also accepts the space-separated rgb() and hsl() forms this tool emits. HWB is handy when you want to dial whiteness and blackness directly, and CMYK exists mainly for print workflows rather than screen CSS.

Why does my HSL lightness look different from the HEX value?

HSL lightness is a perceptual-style slider, not a straight percentage of the RGB channels, so a color at 50% lightness can still have very different channel values depending on hue and saturation. When you convert HEX to HSL, the tool computes hue from the dominant channel, saturation from the channel spread, and lightness from the average of the brightest and darkest channels, which is why the numbers rarely look like simple fractions of 255. Round-tripping a value through both formats stays accurate to within one channel unit.

Can I convert CMYK colors for print?

Yes, the CMYK row converts using the standard naive formulas, which are accurate enough for screen previews and specification documents. Real print shops use ICC profiles and device-specific ink limits, so a naive conversion is only a starting point that a commercial printer should re-separate. Treat the CMYK output here as a communication aid for brand sheets, not as a press-ready separation.

What is the contrast ratio panel for?

The contrast panel computes the WCAG 2.1 contrast ratio between any two colors using the relative luminance formula, which is the same math accessibility auditors use. Ratios of 4.5 or higher pass AA for normal text, 3 or higher passes AA for large text, and 7 or higher passes AAA. Designers use it while picking palette colors so that body text and button labels already meet the bar before a single line of production CSS is written.

Does this converter send my colors anywhere?

No. All parsing and conversion math runs in your browser tab with plain JavaScript arithmetic, and the page has no backend or network call in the conversion path. That makes it safe to use with unreleased brand colors and client palettes under non-disclosure agreements, because nothing about the value you paste leaves the machine.

Why do HWB values sometimes collapse to grey?

In the HWB model, whiteness plus blackness cannot exceed 100%. When the two values add up to 100 or more, the hue component is discarded entirely and the result is a pure grey whose level comes from the ratio of whiteness to the total. The tool follows the CSS Color 4 rule for this case, so hwb(0 50% 50%) correctly produces mid grey instead of any trace of red.

Related color and design tools