WebTooli

HEX to RGB Converter - Free Online Colour Format Tool

Convert HEX colours to every CSS format a developer needs: RGB, RGB percentages, HSL, HSLA, RGBA, 8-digit HEX, and CSS variables. Includes WCAG contrast checker, nearest CSS named colour match, recent colours history, URL sharing, channel breakdown, and live preview. Free, private, no signup.

1. Colour Input HEX · Picker · RGB sliders

Accepts 3-digit (#F00), 6-digit (#FF0000), and 8-digit (#FF0000FF) formats. Click the swatch to open your browser's colour picker.
100% (0% = transparent, 100% = opaque)
Nearest CSS named colour
seagreen
#2E8B57 · distance 38
Recent: No colours yet — your recent colours will appear here
#059669 rgb(5, 150, 105)
Luminance: 0.245 Contrast vs white: 4.52
5 (2.0%)
150 (58.8%)
105 (41.2%)
Each channel ranges from 0 to 255 (equivalent to 0%–100% in CSS percentage syntax).

2. CSS-Ready Code Click any Copy button

3. Channel Breakdown Values & percentage ranges

ChannelValuePercentageCSS Range

4. Accessibility — WCAG Contrast AA / AAA checker

On White Background
Sample Text
4.52:1
On Black Background
Sample Text
4.65:1
ℹ️ WCAG guidance: 4.5:1 minimum for normal text (AA), 7:1 for enhanced contrast (AAA), 3:1 for large text (18pt+ or 14pt bold) and UI components.

5. Colour Variations Click to load into editor

All conversions run in your browser. No data is uploaded or stored. Recent colours and your last-used value are saved locally on your device only.

One HEX code. Nine CSS formats. Zero guessing.

You have a HEX colour. You need it as rgb() for one project. As hsl() for another. As a CSS variable for your design system.

Most converters give you one format. You copy. You convert again. You repeat.

This tool gives you every format at once. RGB, RGB percentages, HSL, HSLA, RGBA, 8-digit HEX, and CSS variables.

Each one has its own copy button. Paste it where you need it. Done.

What you get

HEX. The base format. #059669.

HEX + Alpha. 8-digit version. #059669FF. The last two digits control opacity.

RGB. Classic syntax. rgb(5, 150, 105). Three channels from 0 to 255.

RGB Percentages. Modern syntax. rgb(2% 59% 41%). Same colour, different notation.

RGBA. RGB with alpha. rgba(5, 150, 105, 0.80). Alpha runs from 0 to 1.

HSL. Hue, saturation, lightness. hsl(161deg 94% 30%). Easier for colour variations.

HSLA. HSL with alpha. hsla(161, 94%, 30%, 0.80).

CSS Custom Property. --brand-color: #059669;. Ready for your design system.

CMYK. For print. cmyk(95% 0% 30% 41%). Not supported in CSS. Useful for design handoff.

Why HSL beats RGB for colour work

RGB has three independent channels. Change one and you change the colour in a way that is hard to predict.

HSL separates hue from lightness. Want a darker shade? Lower the L value. Want a muted version? Lower the S value.

The hue stays the same. That makes HSL the better choice for building colour systems.

This tool shows you both. You decide which works for your project.

WCAG contrast checker

Every colour needs to pass accessibility standards. WCAG defines three thresholds.

4.5:1 for normal text (AA). 7:1 for enhanced contrast (AAA). 3:1 for large text and UI components.

The tool calculates the contrast ratio against both white and black backgrounds. Each gets a grade.

If your colour fails, you know before you ship. No surprises in an accessibility audit.

Nearest CSS named colour

Sometimes you need a named colour. Not a HEX code.

The tool finds the closest match from the 148 CSS named colours. It uses redmean distance, which is more accurate than simple RGB distance.

You see the name, the HEX value, and the distance score. If the match is close, you can use the name in your CSS.

Colour variations and harmonies

The tool generates ten variations from any colour. Lighter and darker shades. Complement. Analogous. Triadic.

Click any swatch to load it into the editor. The tool recalculates everything.

This is useful for building palette ramps or exploring colour combinations.

Recent colours and sharing

Every colour you use is saved to a recent list. Up to ten colours. Click a chip to reload it.

The "Copy shareable link" button gives you a URL. It contains the current colour and alpha. Share it with a teammate or bookmark it.

When someone opens the link, the tool loads that exact colour. No manual entry.

Privacy and speed

Everything runs in your browser. No uploads. No accounts. No ads inside the tool.

Recent colours and your last-used value are saved in localStorage on your device. Clear your browser data and they are gone.

Use it for quick conversions or full colour exploration. The numbers never leave your machine.

Frequently Asked Questions

How do I convert HEX to RGB in CSS?
Split the 6-digit HEX into three pairs. Convert each pair from base-16 to decimal. #059669 becomes rgb(5, 150, 105). The tool does this automatically and gives you the CSS declaration ready to paste.
What is the difference between HSL and RGB?
RGB has three independent channels. Red, green, blue. Each from 0 to 255. HSL separates hue from lightness and saturation. HSL is easier for creating variations. You lower the L value to darken. You lower the S value to mute. The hue stays the same.
How is the WCAG contrast ratio calculated?
The ratio uses the WCAG 2.1 formula: (L1 + 0.05) ÷ (L2 + 0.05). L1 is the lighter relative luminance. L2 is the darker. Relative luminance is computed from sRGB values with gamma correction. 4.5:1 passes AA for normal text. 7:1 passes AAA.
← Back to all tools