Color Converter & Validator
Paste any CSS colour — hex, rgb(), hsl(), hwb() or a named colour. It is validated and converted to HEX, RGB, HSL, HWB, HSV, CMYK and OKLCH.
✓ Valid colour — detected format: HEX (6 digits)
Converted values
- HEX
#FF6347 - HEX8
#FF6347FF - RGB
rgb(255, 99, 71) - HSL
hsl(9, 100%, 64%) - HWB
hwb(9 28% 0%) - HSV / HSB
hsv(9, 72%, 100%)not valid CSS - CMYK
cmyk(0%, 61%, 72%, 0%)naive formula, no ICC profile - OKLCH
oklch(69.62% 0.1955 32.32) - CSS name
tomato
What this colour converter does
Colours travel between tools in many notations. A designer hands over #2563EB, a design-token file stores hsl(221 83% 53%), a modern stylesheet wants oklch(), and an older codebase is full of rgba(). This tool takes any of those, tells you whether it is actually valid CSS, and shows the same colour in every common format so you can copy the one you need.
It doubles as a hex colour validator. Instead of quietly fixing mistakes the way browsers do, it explains them: a hex code with five digits, a stray g, a channel of 300 or an alpha of 1.5 all produce a specific error message.
How to use it
- Type or paste a value into the Color value field, or choose one with the colour picker next to it.
- Read the status line below the field: a check mark with the detected format, or the reason the value was rejected.
- Use one of the Examples buttons if you want to see how a particular syntax is written.
- Copy any line of the Converted values table with its Copy button.
- Check the preview and the WCAG contrast box to see how white or black text reads on the colour.
Worked example
Entering rgb(37 99 235 / 80%) (modern space-separated syntax with an alpha of 80%) is detected as RGBA and produces:
HEX #2563EB (alpha dropped) HEX8 #2563EBCC RGBA rgba(37, 99, 235, 0.8) HSLA hsla(221, 83%, 53%, 0.8) HWB hwb(221 15% 8% / 0.8) HSV hsv(221, 84%, 92%) CMYK cmyk(84%, 58%, 0%, 8%) OKLCH oklch(54.61% 0.2152 262.88 / 0.8)
The contrast panel reports 5.17:1 against white text (passes AA) and 4.06:1 against black text (large text only). Contrast is measured on the opaque colour, because the real result of a translucent colour depends on what is behind it.
What each output means
- HEX / HEX8 — two hexadecimal digits per channel. HEX8 adds the alpha channel as a fourth pair (
CC≈ 80%). - RGB(A) — red, green and blue from 0 to 255, plus alpha from 0 to 1.
- HSL(A) — hue angle, saturation and lightness. Handy for building lighter or darker variants by hand.
- HWB — hue plus how much white and black are mixed in; valid in all current browsers.
- HSV / HSB — the model used by most design-app colour pickers. It is not a CSS function, so it is shown for reference only.
- CMYK — the naive formula
K = 1 − max(R,G,B). It ignores ink and paper profiles. - OKLCH — lightness, chroma and hue in the perceptually uniform OKLab space. Equal lightness steps look equally different, which makes it the best choice for generated palettes and theme scales.
- CSS name — shown only when the colour exactly matches one of the 148 named colours.
Limitations
Everything is converted through 8-bit sRGB, so wide-gamut inputs such as color(display-p3 …), lab() or an oklch() value outside sRGB are not accepted as input. Integer outputs are rounded, so converting HSL back and forth can shift a channel by one. The none keyword and relative colour syntax are not supported.
Tips and common mistakes
- Do not mix syntaxes:
rgb(255, 0, 0 / 50%)is invalid. Use commas everywhere or spaces with a slash before alpha. - In hsl(), saturation and lightness need the % sign.
hsl(120, 100, 50)is rejected. - Four-digit hex is
#RGBA, not a typo —#f008is red at about 53% opacity. - Need to check a text/background pair? Use the contrast checker. To build a full scale from one colour, try the color palette generator.
Frequently Asked Questions
Which colour formats can I paste?
Hex with 3, 4, 6 or 8 digits (#RGB, #RGBA, #RRGGBB, #RRGGBBAA), rgb() and rgba() in comma or modern space syntax with numbers or percentages, hsl() and hsla() with deg, rad, grad or turn hues, hwb(), the 148 CSS named colours and the keyword transparent.
How do I check whether a hex colour code is valid?
Type it into the Color value field. A valid code shows a green check with the detected format; an invalid one shows the exact problem, such as a wrong number of digits or a non-hexadecimal character.
Why is rgb(300, 0, 0) rejected?
RGB channels must be between 0 and 255 (or 0% and 100%). Browsers silently clamp out-of-range values, which hides typos, so this tool reports them as errors instead of guessing.
How accurate is the OKLCH value?
It uses the published OKLab matrices by Björn Ottosson with the standard sRGB transfer function, so #FF0000 gives oklch(62.8% 0.2577 29.23), matching what browsers compute. Values are rounded for display.
Is the CMYK value print-ready?
No. It uses the simple device-independent formula without an ICC colour profile. Real print conversion depends on the paper and press profile, so use it as a rough starting point only.
Is my data sent to a server?
No. Parsing and conversion run entirely in your browser with JavaScript; nothing you type is uploaded or stored.
Related tools
- Color Contrast CheckerCheck WCAG 2.1 color contrast ratio between foreground and background colors. Shows AA/AAA pass/fail for normal and large text. Essential for accessible design.
- CSS Shadow GeneratorGenerate CSS box-shadow and text-shadow visually with live preview. Adjust offset, blur, spread, color, and opacity. Copy ready-to-use CSS code.
- Random Color GeneratorGenerate random colors with live preview. Lock individual channels, copy HEX/RGB/HSL values, and generate multiple colors at once for palettes.
- Color Palette ExtractorUpload an image and extract its dominant color palette in HEX, RGB, and HSL formats.
- CSS Gradient GeneratorCreate beautiful CSS gradients visually with live preview. Linear, radial, and conic gradients with unlimited color stops.
All Color & Design tools · Found a bug or a wrong result? Report it.