🏠 Home 🎨 Curated Palettes (400+) ⚡ 100,000+ Colors Matrix đŸ–ŧī¸ Extract Colors from Image ✨ Palette Studio 🌈 Tailwind Shades (50-950) đŸ”Ŧ HEX Color Inspector 🔄 Color Code Converter đŸ‘ī¸ WCAG Contrast Checker 📚 Design Guides Hub 📰 Design & Color Blog â„šī¸ About Us âœ‰ī¸ Contact Support
⚡ Real-Time Math & CSS Tokens

RGB to HEX & HEX to RGB Color Converter

Convert seamlessly between HEX, RGB, HSL, HSV, and CMYK formats. Test WCAG 2.1 contrast ratios against light and dark surfaces, and copy production CSS code instantly.

Click Swatch to Pick
Contrast on White (#FFFFFF): 4.5:1 (AA)
Contrast on Black (#000000): 4.7:1 (AAA)
Popular Colors

How HEX and RGB Color Codes Work in Web Development

Every digital display uses tiny subpixels of Red, Green, and Blue (RGB) light to render color. Understanding how hexadecimal math translates into display signals is essential for optimizing design systems and writing clean CSS.

1. Hexadecimal Color Math Explained

A standard 6-digit hex code represents a base-16 number where each digit ranges from 0 to 15 (0–9 followed by A–F). The 6 characters are split into three pairs:

/* Formula: Converting #2563EB to RGB */ R = (2 × 16) + 5 = 37 G = (6 × 16) + 3 = 99 B = (14 × 16) + 11 = 235 /* CSS Equivalents */ background-color: #2563eb; background-color: rgb(37, 99, 235); background-color: hsl(221, 83%, 53%);

2. When to Use HEX vs. RGB vs. HSL

Different color formats excel in different frontend scenarios:

Frequently Asked Questions

How do I convert HEX to RGB in my head? +
Multiply the first hex character by 16 and add the second character value (where A=10, B=11, C=12, D=13, E=14, F=15). For example, 3A = (3×16) + 10 = 58. Repeat for the green and blue character pairs.
Why does HSL make design system development easier? +
HSL maps directly to human perception. Hue (0–360°) controls the rainbow color family, Saturation (0–100%) controls vibrancy, and Lightness (0–100%) controls illumination. This allows you to generate accessible 50-950 scales using single-variable CSS math.
What is WCAG AA and AAA color contrast? +
The Web Content Accessibility Guidelines (WCAG 2.1) require normal body text to achieve at least a 4.5:1 contrast ratio against its background (Level AA), or 7:1 for enhanced accessibility (Level AAA). For large headings (18pt+ or 14pt bold), 3:1 is required.
Copied to clipboard!