Color Converter
Paste a HEX code, rgb(), hsl(), oklch() or a color name and get every format at once, plus a WCAG contrast check and matching palettes.
Not a color — try #6366f1, #fff, rgb(99, 102, 241), hsl(239 84% 67%), oklch(58% 0.2 277) or a CSS name like coral.
Closest CSS name: mediumslateblue
vs white
—
vs black
—
RGB
HSL
HSV / HSB
CMYK
OKLCH
Contrast checker (WCAG 2.2)
Your color is the text. Background:
Contrast ratio
4.46:1
- AA · normal text (4.5:1)—
- AA · large text (3:1)—
- AAA · normal text (7:1)—
- AAA · large text (4.5:1)—
- AA · UI and graphics (3:1)—
Palettes from this color
Tints and shades
Tap a swatch to load it into the converter. Harmonies rotate the hue around the HSL color wheel; tints and shades mix in white or black.
Why convert color codes?
Every tool speaks a different color language: CSS takes HEX, rgb(), hsl() and now oklch(), design apps show HSB, and print shops ask for CMYK. This converter turns any of them into all the others at once, checks whether text in that color is readable on its background, and suggests palettes, all in your browser.
How to use the color converter
- Type or paste a color into the top box (
#ff7f50,rgb(255 127 80),hsl(16 100% 66%),oklch(73.5% 0.168 40.2)orcoral), or use the picker. - Read or copy any format. You can also edit the RGB, HSL, HSV, CMYK or OKLCH numbers directly; everything else follows.
- Check contrast against a background in the Contrast checker; if it fails, Use it applies the closest color that passes.
- Tap a palette swatch to explore it, or copy the palette as CSS variables. Share link copies a link to this exact color.
Color formats explained
| Format | Coral written as | Used in |
|---|---|---|
| HEX | #ff7f50 | CSS, HTML, design handoff; two hex digits per channel |
| RGB | rgb(255, 127, 80) | Screens, CSS, image editors; 0–255 per channel |
| HSL | hsl(16, 100%, 66%) | CSS; hue angle plus saturation and lightness |
| HSV / HSB | hsv(16, 69%, 100%) | Color pickers in Photoshop, Figma and most apps |
| CMYK | 0% 50% 69% 0% | Print: cyan, magenta, yellow and black ink |
| OKLCH | oklch(73.5% 0.168 40.2) | Modern CSS; perceptual lightness, chroma and hue |
How to convert HEX to RGB (and back) by hand
A six-digit HEX code is three pairs of hexadecimal digits: red, green and blue. Convert each pair from base 16 to base 10: the first digit times 16 plus the second, where A–F stand for 10–15. For #6366f1: 63 = 6 × 16 + 3 = 99, 66 = 6 × 16 + 6 = 102 and f1 = 15 × 16 + 1 = 241, so the color is rgb(99, 102, 241). Going the other way, divide each channel by 16: the whole part and the remainder are the two hex digits (241 = 15 × 16 + 1 → f1). A three-digit code doubles each digit, so #0af is #00aaff. Our number base converter does the same base-16 arithmetic for any number.
HSL vs HSV: which one do you want?
Both describe a color by its hue, the angle on the color wheel (0° red, 120° green, 240° blue), but they measure brightness differently. In HSL, lightness runs from black at 0% through the pure color at 50% to white at 100%, which makes it handy for CSS themes: keep the hue, change the lightness. In HSV (also called HSB), value 100% is the brightest version of the color and saturation fades it toward white, which matches the square picker in most design apps. The same coral is 100% saturated in HSL but 69% in HSV, so copy the numbers from the model your tool expects.
OKLCH: the modern CSS color format
OKLCH, supported by every current browser, describes color the way people see it: L is perceived lightness (0–100%), C is chroma, or colorfulness (0 for grey, up to about 0.32 inside the sRGB range of ordinary screens), and H is the hue angle. Equal steps in L look like equal steps in brightness, which HSL can't promise: yellow and blue at the same HSL lightness look very different. That is why design systems such as Tailwind CSS v4 now define their palettes in OKLCH. If you type an OKLCH color that screens can't show, the converter lowers its chroma until it fits rather than clipping a channel, and tells you it did.
CMYK conversion and printing
Screens add light (RGB); printers subtract it with ink (CMYK). The formula used here is the standard device-independent one: K = 1 − max(R, G, B), then each of C, M and Y is scaled from what remains. It gives a sensible starting point, but real ink values depend on the paper, the press and its ICC color profile, and many bright screen colors, especially saturated greens and blues, can't be printed at all. For anything color-critical, ask your printer for a proof.
Contrast ratios and WCAG
The Web Content Accessibility Guidelines measure contrast as (L1 + 0.05) / (L2 + 0.05), where L1 and L2 are the relative luminances of the lighter and darker color; it runs from 1:1 (identical) to 21:1 (black on white). Level AA asks for at least 4.5:1 for normal text and 3:1 for large text (24 px, or 18.66 px bold) and for icons and input borders; level AAA asks for 7:1 and 4.5:1. Ratios are truncated, never rounded up: 4.49:1 fails AA. The popular indigo #6366f1 reaches only 4.46:1 on white, so it fails AA for body text; the checker's suggestion, a barely darker #6365f0, passes at 4.51:1.
Common mistakes
- Confusing HSL with HSB. Pasting HSB numbers from a design app into CSS's hsl() gives a different color.
- Forgetting that 8-digit HEX has alpha.
#6366f180is the same color at 50% opacity. This converter accepts it but works with the solid color, because contrast depends on what's behind a translucent color. - Trusting rounded contrast. A tool that shows 4.5:1 for 4.496 hides a failure; this one truncates.
- Expecting screen colors in print. Convert to CMYK early and check a printed proof.
More tools for design work: build a full color scheme with locked colors, contrast and color-blindness checks in the color palette generator, get the exact color of any pixel in a photo or screenshot with the image color picker, choose QR code colors with enough contrast in the QR code generator, shrink CSS with the code minifier, or prepare images with resize image and convert image.
Frequently asked questions
How do I convert HEX to RGB?
Paste the HEX code into the top box and read the RGB values below, or copy them as rgb(…). By hand, split the code into three pairs and convert each from base 16: #6366f1 becomes 63 → 99, 66 → 102 and f1 → 241, so rgb(99, 102, 241). A three-digit code such as #0af doubles each digit first (#00aaff).
How do I convert RGB to HEX?
Type the three numbers into the RGB fields, or paste rgb(255, 127, 80) or simply 255, 127, 80 into the top box, and the HEX code appears at once. By hand, write each channel as two hexadecimal digits: 255 = ff, 127 = 7f, 80 = 50, giving #ff7f50.
What color formats can I type in?
HEX (3, 4, 6 or 8 digits), rgb() and rgba() in comma or space syntax with numbers or percentages, hsl() and hsla() with optional deg, rad, grad or turn hue units, oklch() and oklab(), a plain 99, 102, 241 triple, and all 148 CSS color names with both gray and grey spellings. You can also edit the RGB, HSL, HSV, CMYK and OKLCH numbers directly; out-of-range values are brought into range.
What is OKLCH and why use it?
OKLCH is a newer CSS color format based on the OKLab color space: L is perceived lightness, C is chroma (colorfulness) and H is the hue angle. Unlike HSL, colors with the same L look equally bright, which makes it easier to build accessible palettes and consistent hover states. All current browsers support oklch() in CSS. If a value is outside what screens can show, the converter reduces its chroma to the nearest displayable color and says so.
What's the difference between HSL and HSV (HSB)?
Both use a hue angle plus two percentages, but they model brightness differently. In HSL, lightness 50% is the pure color, 0% is black and 100% white. In HSV, also called HSB, value 100% is the brightest version of the color and lowering saturation fades it toward white. CSS uses HSL; most design-app color pickers use HSB, so the numbers aren't interchangeable.
What contrast ratio do I need for WCAG?
WCAG 2.2 level AA needs at least 4.5:1 for normal text and 3:1 for large text (24 px, or about 18.7 px bold) and for icons, focus rings and input borders. Level AAA needs 7:1 for normal text and 4.5:1 for large text. The contrast checker tests your color against any other color as text or background and, when it fails AA, offers the closest shade that passes.
Why does this tool show 4.46:1 where another shows 4.5:1?
WCAG ratios must not be rounded up: a color pair at 4.497:1 fails the 4.5:1 requirement. This converter truncates to two decimals, so what you see is always on the safe side; some tools round to one decimal and display a failing pair as 4.5:1.
Is the CMYK conversion accurate for printing?
It uses the standard formula (K = 1 − the largest of R, G and B, then C, M and Y from what remains), which is a good starting point. Exact ink values depend on the printer, paper and ICC color profile, and some bright screen colors can't be printed at all, so check a proof for color-critical work.
How do I find colors that go well together?
The Palettes section builds tints and shades of your color (mixed with white and black) and classic color-wheel harmonies: complementary, analogous, triadic, split-complementary and tetradic. Tap any swatch to load it into the converter, or copy the tint-and-shade scale as CSS custom properties.
Does it handle transparency (alpha)?
It accepts colors with alpha, such as #6366f180 or rgba(99, 102, 241, 0.5), but converts the solid color and ignores the transparency. HSV and CMYK have no alpha channel, and the contrast of a translucent color depends on what is behind it.
Why do HSL or CMYK values change slightly after I type them?
Every color is stored as 8-bit RGB, with 256 levels per channel, and the other formats are calculated from it and rounded. Typing hsl(210, 50%, 40%) picks the nearest RGB color, rgb(51, 102, 153); some other values come back one unit different because two nearby HSL values map to the same RGB color.
Is my data uploaded anywhere?
No. All color math runs in your browser and nothing is sent to a server. The last color you used and your contrast-checker background are remembered on this device so they're there next time; a shared link carries the color after the # sign, which browsers don't send to the server.
Related tools
More free, private, browser-based utilities — no upload, no sign-up.