Hex to RGB Color Converter

Convert hex color codes to RGB, HSL, and CMYK values instantly. Also converts RGB to hex. Preview colors in real-time and copy CSS-ready code. Free, fast, and private.

Ad Space

How Hex to RGB Conversion Works

A hex color code is a 6-digit hexadecimal representation of a color. The first two digits represent red, the next two green, and the last two blue. Each pair converts to a decimal value between 0 and 255. For example, #FF5733 means Red=255, Green=87, Blue=51. This hex to RGB converter handles both 3-digit shorthand (#F00) and 6-digit (#FF0000) formats.

Conversion Formula

Hex → RGB: #D9FE06 → R:217, G:254, B:6

Each hex pair: D9₁₆ = 13×16 + 9 = 217

RGB → Hex: rgb(255, 87, 51) → #FF5733

Color Models Explained

Different color models serve different purposes. RGB (Red, Green, Blue) is used for screens and digital displays — it's additive, meaning colors are created by combining light. CMYK (Cyan, Magenta, Yellow, Key/Black) is used for printing — it's subtractive, meaning colors are created by absorbing light. HSL (Hue, Saturation, Lightness) is more intuitive for humans to understand and adjust.

Hex Colors in CSS

Web developers use hex color codes extensively in CSS. The format #RRGGBB is the standard, with #RGB as shorthand (e.g., #F00 = #FF0000). Modern CSS also supports rgba() for transparency. When working with design systems, you may need to convert between hex, RGB, and HSL formats — this converter handles all three plus CMYK for print work.

When to Use Each Color Format

Use hex (#RRGGBB) in CSS for clean, compact color codes. Use RGB when you need to programmatically calculate colors or add transparency (rgba). Use HSL when adjusting color variations — changing lightness or saturation is intuitive in HSL. Use CMYK only for print design — web colors should always use RGB-based formats.

Common Conversion Tips

Always verify the source and target units or formats before converting — selecting the wrong option is the most common mistake. For precise conversions, enter values with as many decimal places as you have available. If converting multiple items, work through them one at a time to avoid mixing up results. Bookmark this page for quick access when you need to convert again in the future.

Frequently Asked Questions

What is a hex color code?

A hex color code is a 6-digit hexadecimal number prefixed with # that represents a color. The digits are grouped in pairs: the first two represent red, the middle two green, and the last two blue. Each pair ranges from 00 (0) to FF (255).

What is the difference between hex and RGB?

Hex and RGB represent the same colors in different formats. Hex uses a single string (#FF5733), while RGB uses three separate values (255, 87, 51). Both define red, green, and blue components — hex in base-16, RGB in base-10.

Can I use 3-digit hex codes?

Yes. 3-digit hex codes like #F00 are shorthand where each digit is doubled: #F00 = #FF0000. This converter accepts both 3-digit and 6-digit formats.

What is HSL color?

HSL stands for Hue (0-360°), Saturation (0-100%), and Lightness (0-100%). It is more intuitive than RGB for adjusting colors — changing lightness makes a color lighter/darker, changing saturation makes it more/less vivid.

When should I use CMYK vs RGB?

Use RGB (or hex) for anything displayed on screens — websites, apps, digital design. Use CMYK for print materials — business cards, flyers, packaging. Colors may look different between screen and print due to the different color models.