Online Color Converter - HEX, RGB, HSL

Convert colors between different formats (HEX, RGB, HSL) with ease. A visual and intuitive tool for developers and designers to work with colors in their projects.

Color Convert

#3b82f6

Clique para selecionar uma cor

🎨 About Color Formats
  • HEX: Hexadecimal format (#RRGGBB) used in CSS and design
  • RGB: Red, Green, Blue (0-255) - common format in programming
  • HSL: Hue, Saturation, Lightness - more intuitive for adjustments
  • RGBA/HSLA: Include alpha channel (transparency from 0 to 1)

Color Formats Explained

🎨 HEX

Example: #3B82F6

6-digit hexadecimal format (RRGGBB). Each pair represents Red, Green, and Blue in values from 00 to FF.

🔢 RGB

Example: rgb(59, 130, 246)

Values from 0-255 for Red, Green, and Blue. More intuitive format for programming.

🌈 HSL

Example: hsl(217, 92%, 60%)

Hue (0-360°), Saturation (0-100%), Lightness (0-100%). More intuitive for color adjustments.

When to Use Each Format?

HEX (#RRGGBB)

  • ✅ Best for: CSS, design, fixed color values
  • ✅ Advantages: Compact, widely supported, easy to copy
  • ❌ Disadvantages: Hard to understand visually, no native transparency support (use 8 digits: #RRGGBBAA)

RGB / RGBA

  • ✅ Best for: JavaScript, dynamic color manipulation, transparency
  • ✅ Advantages: Easy to manipulate programmatically, alpha support
  • ❌ Disadvantages: Less compact, values not as intuitive

HSL / HSLA

  • ✅ Best for: Creating color variations, themes, dynamic adjustments
  • ✅ Advantages: Very intuitive, easy to adjust hue/saturation/brightness
  • ❌ Disadvantages: Less familiar to some developers

Understanding HSL

HSL is especially powerful for creating color variations:

Practical Use Cases

🎨 Design Systems

Use HSL to generate consistent color scales. Keep hue and saturation constant, vary only lightness to create primary-100, primary-200, etc. colors.

🌙 Dark Mode

Convert your colors to HSL and adjust lightness automatically. Light colors become dark and vice-versa, maintaining color identity.

♿ Accessibility

Use RGB to calculate color contrast and ensure text is readable over backgrounds. WCAG requires a minimum ratio of 4.5:1 for normal text.

Code Examples

CSS with Variables

:root {
  --primary-hue: 217;
  --primary-sat: 92%;
  
  --primary: hsl(var(--primary-hue), var(--primary-sat), 60%);
  --primary-light: hsl(var(--primary-hue), var(--primary-sat), 80%);
  --primary-dark: hsl(var(--primary-hue), var(--primary-sat), 40%);
}

JavaScript - Dynamic Manipulation

// Darken an RGB color
function darkenColor(r, g, b, amount) {
  return `rgb(${Math.max(0, r - amount)}, ${Math.max(0, g - amount)}, ${Math.max(0, b - amount)})`;
}

// Adjust transparency
const color = 'rgba(59, 130, 246, 0.5)'; // 50% transparent

Pro Tips

Frequently Asked Questions

Which format is most performant?

There is no significant performance difference. Use the format that makes most sense for your use case. Browsers convert everything internally anyway.

How to convert colors in CSS?

CSS doesn't convert automatically, but you can use tools like this one, preprocessors (Sass/Less) with conversion functions, or CSS custom properties with calc().

What is 8-digit HEX?

#RRGGBBAA adds an alpha channel (transparency) at the end. For example, #3B82F680 is blue with 50% transparency. Supported in modern browsers and CSS.