🎨 Hex ↔ RGB Color Converter

Convert between hex, RGB, HSL color formats with live preview.

HEX#6C63FF
RGBβ€”
RGBA (50%)β€”
HSLβ€”
CSS Varβ€”

How to Use This Tool

Click the color picker to select any color visually, or type a hex code directly in the Hex Code field. You can also drag the R, G, B sliders to fine-tune individual channels. All output formats update instantly.

1

Click the color picker or type a 6-digit hex code like #FF5733 in the input field.

2

View the converted values: RGB, RGBA at 50% opacity, HSL, and CSS variable format.

3

Use the R, G, B sliders to adjust individual channels and see the hex and HSL update in real time.

4

Click Copy Hex, Copy RGB, or Copy HSL to grab the format you need.

When to Use Hex, RGB, and HSL in CSS

Hex codes like #6C63FF are the most compact color notation and work everywhere in CSS. They are ideal for design tokens and static color values. RGB notation gives you arithmetic flexibility: if you store colors as CSS custom properties, you can use them in rgba(var(--color-primary-rgb), 0.4) to create transparent variants without rewriting the hex. HSL is the format to reach for when you want to programmatically generate color scales. Adjusting only the L (lightness) value from 20% to 90% while keeping hue and saturation fixed gives you a consistent tint stack for a component library. For example, the color hsl(243, 100%, 69%) is the blue-purple #6C63FF. Changing L to 95% gives a very light background tint; changing L to 30% gives a dark pressed state, all from the same hue. This is why design systems like Tailwind generate their palettes in HSL. Knowing how to convert quickly between these formats saves time when matching a designer's Figma spec to your actual CSS code.

Common Use Cases

Matching a Figma color to CSSCopy the hex from Figma and get the RGB/HSL for your design token
Building a color scaleUse HSL output to create consistent light and dark variants of a brand color
Opacity variants in CSSGet the RGB values to use with rgba() for hover and overlay states
Accessibility contrast checksConvert both foreground and background to RGB before running contrast ratio math

Frequently Asked Questions

What is a hex color code?

A hex color is a 6-digit hexadecimal number representing RGB values: #RRGGBB. Each pair (00–FF) represents a channel value 0–255.

How to convert hex to RGB?

Split the hex code into R, G, B pairs and convert each from hex to decimal. E.g. #FF5733: R=255, G=87, B=51.

What is HSL?

HSL (Hue, Saturation, Lightness) is a more intuitive color model. Hue is 0–360Β°, saturation and lightness are 0–100%.

What is the difference between HSL and HSB?

HSB (also called HSV) uses Brightness instead of Lightness. Pure colors have B=100%, S=100%. In HSL, pure hues sit at L=50%.

What is rgba?

rgba adds an alpha (opacity) channel: rgba(255, 87, 51, 0.5) for 50% transparent orange.