ToolBook
Support us on Ko-fi
Help us keep this free, forever

Color Code Converter

How to convert between color formats

Type or paste a color in any format and all other formats update instantly.

  1. Enter a color

    Type a HEX value (e.g. #1a73e8), a CSS color name (e.g. "steelblue"), RGB values (26, 115, 232), HSL values (217, 79%, 51%), or HSV values into the corresponding fields. You can also click the swatch to open the native color picker.

  2. See all conversions

    All four formats update automatically the moment you type. The full-width swatch at the top shows the live color preview.

  3. Copy a value

    Click the copy button next to any field to copy the formatted value to your clipboard — ready to paste into CSS, Figma, or code. The CSS-ready bar at the bottom gives pre-formatted rgb() and hsl() strings in one click.

  4. Check WCAG contrast

    Scroll to the WCAG Contrast panel to see contrast ratios against white and black. A ratio of 4.5:1 or above passes WCAG AA for normal text. Use this to verify accessibility before using the color in a UI.

Frequently asked questions

What is the difference between HEX, RGB, HSL, and HSV?

HEX (#rrggbb) is a six-character hexadecimal notation used in HTML/CSS — each pair encodes a red, green, or blue channel from 00 to FF. RGB splits the same three channels as decimal integers (0–255). HSL describes color as Hue (0°–360°), Saturation (0%–100%), and Lightness (0%–100%) — intuitive for humans: spin the hue wheel to change color, adjust lightness to brighten or darken. HSV (Hue, Saturation, Value) is similar but uses Value instead of Lightness, which maps more naturally to how paint pigments mix.

Can I enter a CSS color name like "rebeccapurple" or "tomato"?

Yes — type any of the 148 standard CSS named colors directly into the HEX field. The tool recognises all CSS Color Level 4 named colors and resolves them instantly to their HEX, RGB, HSL, and HSV equivalents. Try typing "coral", "steelblue", or "goldenrod" and the swatch and all four format cards will update in real time.

How do I check if my color has enough contrast for accessibility?

The WCAG Contrast panel at the bottom of the tool shows the contrast ratio of your color against both pure white and pure black. A ratio of 4.5:1 or higher passes WCAG AA for normal body text; 7:1 or higher passes the stricter AAA standard. Use this to verify that your text and background color pairs meet accessibility requirements before shipping.

Why do my HSL values look different in CSS versus this tool?

CSS `hsl()` rounds differently depending on the browser. This tool rounds hue to the nearest degree and saturation/lightness to the nearest integer — which matches the rounding in most design tools (Figma, Sketch). If you need a pixel-perfect match with a specific browser, test the CSS value directly and adjust by ±1.

How do I use the color picker?

Click the color swatch at the top of the tool. This opens the native OS/browser color picker which lets you visually select any color. The HEX, RGB, HSL, and HSV fields all update instantly. You can also type directly into any of the four format fields and the others will sync automatically.

What is the difference between HSV and HSB?

They are the same color model with two different names. HSV stands for Hue, Saturation, Value; HSB stands for Hue, Saturation, Brightness. Adobe Photoshop and most raster art tools use the HSB label; web documentation and color science literature tend to say HSV. The maths and the numbers are identical.

What is HSV used for vs HSL?

HSV (also called HSB) is the model used in Photoshop and most raster art tools because Value = 100% with Saturation = 0% gives pure white — matching the physical intuition of adding white paint. HSL is more common in CSS/web design because L = 50% at full saturation gives a vibrant mid-range color rather than white, making it easier to build palettes programmatically.

Can I convert CMYK here?

Not yet — CMYK is a subtractive print model that requires knowledge of the target color profile (ICC profile) for accurate conversion. HEX, RGB, HSL, and HSV are all mathematically lossless round-trips between each other, so conversion is exact. CMYK to RGB conversion is an approximation without a full color-managed pipeline.

Color models explained: HEX, RGB, HSL, and HSV — and when to use each

Why four color formats exist, how the math links them together, and which model to choose for CSS, design tools, or image editing.

Why four color models for the same color?

A monitor emits light in three channels — red, green, and blue. Every color you see on screen is a mixture of those three. The four formats this tool handles are just different ways of describing the same physical reality, each optimised for a different use case.

HEX (#1a73e8) is the format HTML and CSS have used since the 1990s. It's compact and copy-pasteable, but communicating "make this 20% lighter" in HEX requires mental gymnastics. That's what HSL is for.

RGB (rgb(26, 115, 232)) expresses each channel as a decimal from 0 to 255. It maps directly to the 8-bit integer the GPU uses, which makes it useful in image processing code — you can add or subtract channel values in a loop.

HSL (Hue, Saturation, Lightness) was designed for human readability. Hue is the position on the color wheel (0° = red, 120° = green, 240° = blue). Saturation is how vivid the color is (0% = grey). Lightness is how bright (0% = black, 100% = white, 50% = the purest version of that hue). If you want to generate a set of colors that all look "the same type of blue but different brightness," you fix H and S and vary L.

HSV (Hue, Saturation, Value) looks similar to HSL but behaves differently: at V=100% and S=0%, you get pure white — which matches the additive paint model used by Photoshop and most raster tools. At V=100% and S=100%, you get the fully saturated hue.

The conversion math

HEX and RGB are trivially equivalent — HEX is just the base-16 representation of the three decimal values. Converting between RGB and HSL/HSV requires normalising the channels to the range 0–1, finding the maximum and minimum channel values, and deriving hue from which channel dominates.

The inverse conversions (HSL → RGB and HSV → RGB) work by computing the chroma component (the distance from grey) and then distributing it across the three channels based on the hue sector. Both paths are mathematically lossless at infinite precision; at integer precision (rounding H to 1°, S/L to 1%) a round-trip may drift by ±1 on a channel value.

Which format to use in CSS?

Modern CSS accepts all four: #hex, rgb(), hsl(), and even relative color functions like hsl(from var(--accent) h s calc(l + 10%)). For design tokens, HSL is the most maintainable because you can tweak lightness without recalculating all three channels. For copy-pasting from a design file (Figma exports HEX by default), #hex is fine. For canvas/WebGL code that loops over pixels, use raw RGB integers.