What Is a Color Converter?
A color converter translates one color notation into another. A designer hands you #FF6B35. Your charting library wants rgb(255, 107, 53). You’d like to build hover states by nudging lightness in hsl(). All three describe the same color, and doing the conversion by hand gets tedious after the first one.
This converter accepts every notation CSS understands for sRGB colors. That’s 3-, 4-, 6- and 8-digit HEX, rgb() and rgba(), hsl() and hsla(), the modern space-separated CSS Color 4 syntax, and all 148 named colors. One input gives you every other format, a preview swatch, a contrast check and ready-made CSS custom properties.
HEX, RGB and HSL Explained
HEX
A HEX color is RGB written in base 16: #RRGGBB, where each pair runs from 00 (0) to FF (255). Three short forms and extensions exist:
- 3 digits
#RGB: each digit is doubled, so#F63means#FF6633. This only works when both digits of every pair are the same. - 8 digits
#RRGGBBAA: a fourth pair sets alpha.#FF6B3580is the same orange at about 50% opacity. - 4 digits
#RGBA: the short form of the above, so#F638means#FF663388.
HEX is case-insensitive, and it’s the most compact form, which is why design tools and style guides default to it.
RGB
rgb(255, 107, 53) gives the red, green and blue channels directly as numbers from 0 to 255. Percentages also work, so rgb(100% 42% 21%) scales each channel to 0-255. RGB maps straight onto how screens mix light, but it’s hard to tweak by hand. Making that orange “a bit darker” means changing all three numbers by different amounts.
HSL
hsl(16, 100%, 60.4%) describes the same orange as a hue angle on the color wheel (0° red, 120° green, 240° blue), a saturation (0% gray to 100% vivid) and a lightness (0% black, 50% pure color, 100% white). It’s the friendliest format for building palettes. Keep hue and saturation fixed and step lightness to get a tint and shade scale for buttons, borders and backgrounds.
How to Use This Color Converter
- Type or paste a color into the input. You can paste a whole CSS declaration such as
background-color: #ff6b35;. The property name,!importantand the trailing semicolon are stripped. - Press Convert or
Ctrl+Enter. You can also click the color swatch next to Convert to open your system color picker. It converts as you drag. - Read off HEX, RGB, HSL, the CSS Color 4 forms, the matching or nearest named color, contrast against white and black, and three CSS variables. Copy everything with the Copy button or
Ctrl+Shift+C.Ctrl+Lclears the input.
If a channel is out of range, for example rgb(300, 0, 0), the tool clamps it the same way browsers do (red becomes 255) and adds a note saying so. That way the HEX and RGB lines always describe the same color.
Converting HEX to RGB (and Back) by Hand
Each HEX pair is one byte. For #FF6B35:
| Pair | Hex | Calculation | Decimal |
|---|---|---|---|
| Red | FF | 15 × 16 + 15 | 255 |
| Green | 6B | 6 × 16 + 11 | 107 |
| Blue | 35 | 3 × 16 + 5 | 53 |
Going the other way, divide each channel by 16. The quotient is the first digit and the remainder is the second: 107 ÷ 16 = 6 remainder 11, which is 6B. The Number Base Converter does the same base-16 arithmetic for any number.
HSL takes more math: you normalize the channels to 0-1, find the largest and smallest, and derive hue from which channel dominates. That’s the conversion people usually reach for a tool to do.
Why HSL Round Trips Drift
Convert #FF6B35 to HSL, round to whole numbers, and you get hsl(16, 100%, 60%). Convert that back and you get #FF6933, not #FF6B35. Nothing is broken. The rounding is too coarse. One percent of lightness is about 2.5 steps on the 0-255 scale, so dropping the 0.4% moves the green and blue channels.
We tested this on 300,000 random colors. Whole-number HSL failed to reproduce the original HEX code about 9 times in 10. With one decimal place, which is what this converter prints (hsl(16, 100%, 60.4%)), every one of those colors came back exactly. If you store design tokens in HSL, keep the decimal.
Modern CSS Color Syntax (CSS Color 4)
CSS Color Module Level 4 simplified the functional notations, and every current browser supports them:
- Spaces instead of commas:
rgb(255 107 53),hsl(16 100% 60.4%). - Alpha after a slash:
rgb(255 107 53 / 50%)or/ 0.5. rgba()andhsla()are now aliases ofrgb()andhsl(). Both forms accept alpha.- Hue units:
deg(the default),turn,radandgrad, sohsl(0.5turn 50% 50%)is the muted cyan#40BFBF.
The converter reads both the legacy comma syntax and the modern syntax and outputs both. Use the legacy form if your code passes through an older CSS minifier or preprocessor that doesn’t understand the slash.
The newer color spaces in CSS Color 4 and 5, such as oklch(), lab(), color(display-p3 ...) and color-mix(), can describe colors outside sRGB. This tool covers the sRGB formats (HEX, RGB, HSL) that the vast majority of stylesheets, design tokens and APIs still exchange.
Named Colors
CSS has 148 named colors, from aliceblue to yellowgreen. If your input matches one exactly, the converter shows its name. Otherwise it shows the nearest named color as a rough description. A few quirks are worth knowing:
grayandgreyare both valid, and so is every*gray/*greypair.darkgray(#A9A9A9) is lighter thangray(#808080). That’s a leftover from the X11 color list the names came from.rebeccapurple(#663399) was added in CSS Color 4 in memory of Rebecca Meyer.transparentisrgba(0, 0, 0, 0): black at zero opacity, which matters when you animate or blend from it.
Contrast and Readable Text
For every color, the tool computes the WCAG 2 contrast ratio against white and against black and tells you which text color reads better on it. WCAG AA requires 4.5:1 for normal text and 3:1 for large text (24px, or about 18.7px bold). AAA requires 7:1. Bright brand oranges are a classic trap: #FF6B35 gives white text only 2.84:1, while black text reaches 7.41:1. Contrast is computed on the opaque color. With transparency, the real result depends on whatever is behind the element.
Using the CSS Variable Output
The output includes three custom properties:
--color: #ff6b35;
--color-rgb: 255, 107, 53;
--color-hsl: 16 100% 60.4%;
--color-rgb holds the bare channels so you can add opacity later: rgba(var(--color-rgb), 0.15) for a translucent background or a box shadow. --color-hsl uses the space syntax so hsl(var(--color-hsl) / 50%) works too. Both are handy for gradients and hover states without defining a second variable.
Common Color Conversion Errors
- Alpha in the wrong place. CSS puts alpha last (
#RRGGBBAA). Android color resources and Flutter’sColor(0xAARRGGBB)put it first. Pasting an Android#80FF6B35into CSS gives you a completely different color. - 0-1 versus 0-255 alpha.
rgba(255, 107, 53, 128)isn’t half-transparent. Alpha above 1 is clamped to fully opaque. Use0.5or50%. - Missing percent signs in
hsl(). The comma syntax requires%on saturation and lightness, so browsers may ignorehsl(16, 100, 60)and leave the property unset. This converter accepts both, but write the%in your CSS. - 5- or 7-digit HEX. Usually a copy-paste that lost a character. Only 3, 4, 6 and 8 digits are valid.
- Values over 255. Browsers clamp
rgb(300, 0, 0)torgb(255, 0, 0)silently. The converter does the same but tells you.