Color Converter
Convert a color between HEX, RGB, and HSL, check its WCAG contrast ratio, and preview a working palette.
- Free
- No account
- Runs in your browser
- Nothing uploaded
#3498dbrgb(52, 152, 219)hsl(204, 70%, 53%)#3498db on #ffffff — not rounded, so a value like 4.49 still fails its 4.5 threshold.
#db7633#3344db#33dbcaRuns entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy
What is Color Converter?
A color in code is just a number, but it gets written several different ways. HEX packs red, green, and blue into a single six-digit string like #3498db. RGB spells the same three channels out as rgb(52, 152, 219). HSL instead describes the color the way you think about it — hue (the shade), saturation (how vivid), and lightness (how bright).
This tool starts from a single color and gives you every representation at once: the exact HEX, the rgb() and hsl() strings you can paste into CSS, and a color preview. It also reports the WCAG 2.x contrast ratio against a second color you choose, so you can verify that text on a background passes accessibility thresholds before you ship it.
Finally, it generates a small working palette — the complementary color (across the color wheel, 180° apart) and two analogous colors (thirty degrees to either side). These are classic starting points for a design.
Everything runs in your browser. Nothing is uploaded, stored, or transmitted — the Privacy Policy promise holds.
Converting between color spaces:
HEX → RGB: each pair of hex digits is one channel. Reading #RRGGBB, red = RR, green = GG, blue = BB, each 0-255. For a three-digit shorthand like #rgb, each digit is doubled: #349 becomes #334499.
RGB → HSL: normalize each channel to 0-1. Max and min give the lightness L = (max+min)/2. If max equals min the color is gray — saturation is 0 and hue is undefined. Otherwise saturation S adjusts with lightness, and hue is computed by which channel is the max:
• max = red: H = 60° × ((G − B)/(max − min)) • max = green: H = 60° × ((B − R)/(max − min) + 2) • max = blue: H = 60° × ((R − G)/(max − min) + 4)
Negative hues wrap to 0-360 by adding 360.
WCAG 2.x contrast ratio — per WCAG 2.2 Understanding SC 1.4.3 (Contrast Minimum):
1. Convert each RGB channel to sRGB-linear-ish 'relative luminance'. For a channel value c in 0-255, cSrgb = c/255, then: cSrgb ≤ 0.04045 → cLin = cSrgb/12.92 cSrgb > 0.04045 → cLin = ((cSrgb + 0.055)/1.055)^2.4 2. L = 0.2126·R + 0.7152·G + 0.0722·B. 3. ratio = (L1 + 0.05)/(L2 + 0.05), where L1 is the lighter of the two and L2 the darker, so the result is always 1-21.
Pass thresholds: AA normal text ≥ 4.5, AA large text ≥ 3, AAA normal text ≥ 7, AAA large text ≥ 4.5. The values are not rounded — 4.49 fails the 4.5 threshold. This tool shows the ratio to two decimals and marks which levels it passes.
Worked examples
- #3498db → rgb(52, 152, 219), hsl(204, 70%, 53%)
- #ff0000 → rgb(255, 0, 0), hsl(0, 100%, 50%)
- #ffffff → rgb(255, 255, 255), hsl(0, 0%, 100%)
- #000000 → rgb(0, 0, 0), hsl(0, 0%, 0%)
- white vs #3498db contrast = 3.15:1 (fails AA for normal text)
- black vs #3498db contrast = 6.66:1 (passes AA and AAA)
- white vs black contrast = 21:1 (maximum possible)
- #3498db palette: complementary #db7633, analogous #3344db and #33dbca
How to use Color Converter
- Type or paste a color in any format — HEX (#3498db), rgb(52, 152, 219), or hsl(204, 70%, 53%).
- The tool shows the color preview, its HEX, rgb(), and hsl() values.
- To check contrast, pick or enter a second color for the background.
- Read the contrast ratio and which WCAG levels it passes.
- Preview the complementary and analogous palette below.
- Copy any value with its copy button.
Common errors
- Entered a hex code as #... must be 3 or 6 hex digits (0-9, a-f) — e.g. #3498db or #fff.
- The color is valid but you wrote 'rgb(52 152 219)' without commas — use rgb(52, 152, 219).
- HSL hue outside 0-360 — wrap or normalize the number to 0-360.
- Contrast says the pair fails when the individual colors are fine — contrast is about the pair; bright text on a bright background always fails regardless of how nice each color looks.
FAQ
What is the difference between HEX, RGB, and HSL?
All three describe the same color as numbers, but organize them differently. HEX is a compact six-digit string (#RRGGBB) encoding red, green, blue values. RGB spells the same three channels out explicitly — rgb(255, 0, 0) is pure red. HSL describes hue (the shade, 0-360°), saturation (vividness, 0-100%), and lightness (0-100%). HSL is often easier to reason about because you can change just the lightness to make a color lighter or darker.
What does a WCAG contrast ratio mean?
It measures how easily text can be distinguished from its background, on a scale of 1 to 21. WCAG 2.x requires minimums: AA needs 4.5:1 for normal text and 3:1 for large text; AAA needs 7:1 for normal and 4.5:1 for large. Values are not rounded, so 4.49 fails even though it is close.
Do HEX and RGB mean exactly the same color?
Yes. #3498db and rgb(52, 152, 219) are the identical color — 0x34 = 52, 0x98 = 152, 0xdb = 219. The only difference is notation. Browsers render both the same way in progressive enhancement, and you can freely switch between them.
What are complementary and analogous colors?
Complementary colors sit opposite each other on the color wheel (180° apart in hue) — they maximize contrast and make each other pop. Analogous colors sit adjacent (30° to each side) and feel harmonious since they share a base hue. Together they form a classic starting palette for a design.
Does this tool support alpha channels or color names?
Design decisions: this tool covers opaque HEX, RGB, and HSL and reads hex-alpha (#RRGGBBAA) by ignoring the alpha, but it expects you to enter a solid color. It deliberately omits named colors (aquamarine, beige, ...) because a reliable lookup needs every CSS color name, and it omits CMYK because converting losslessly from RGB isn't well-defined. We show what we can compute correctly, not a partial approximation.
Related tools
Prefer AllUtil on Google
One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.