Color Code Converter — HEX, RGB & HSL Converter

Convert color codes between HEX, RGB, and HSL formats. Color picker included for quick selection.

#1A73E8
All Formats
HEX#1a73e8
RGBrgb(26, 115, 232)
RGBArgba(26, 115, 232, 1)
HSLhsl(214, 82%, 51%)
HSLAhsla(214, 82%, 51%, 1)
HSVhsv(214°, 89%, 91%)
Name
RGB Sliders
R26
G115
B232
HSL Sliders
H214°
S82%
L51%
Alpha
1.00
Color Info
Hue
214°
Saturation
82%
Lightness
51%
Color Harmony
Complementary
Analogous
Triadic

About Color Code Converter — HEX, RGB & HSL Converter

Color Code Converter instantly converts color values between HEX, RGB, and HSL formats with auto-detection for the input type. It is an essential utility for web designers and front-end developers who need to translate color codes between CSS properties and design tools.

How to Use

  1. 1Enter a color code in the "Color code" field in HEX, RGB, or HSL format.
  2. 2Set the input format to "Auto-detect" or specify the exact format.
  3. 3Click "Convert Color" to see the equivalent values in all three formats.

Features

  • Converts between HEX, RGB, and HSL in one step
  • Auto-detection removes the need to specify the input format
  • Displays all three format outputs simultaneously
  • Essential for translating design tool colors to CSS
01

Color Models Explained

CSS supports multiple color models, each with different strengths. Understanding how RGB, HSL, and HEX relate to each other helps you choose the right format for different tasks.

RGB: The Additive Color Model

RGB (Red, Green, Blue) defines colors by mixing intensities of three light channels, each ranging from 0 to 255. This additive model works like mixing light — combining maximum red (255,0,0), green (0,255,0), and blue (0,0,255) at full intensity produces white (255,255,255), while all channels at zero produce black (0,0,0). RGB is the native model of computer displays, which emit light through red, green, and blue sub-pixels. In CSS, rgb(255, 0, 0) and the modern space-separated syntax rgb(255 0 0) both express pure red. The model is intuitive for developers who think in terms of hardware color channels.

HSL: Human-friendly Color Editing

HSL (Hue, Saturation, Lightness) uses three perceptually meaningful axes. Hue is the color angle on the color wheel from 0 to 360 degrees: 0 and 360 are red, 120 is green, 240 is blue. Saturation is the intensity of the color from 0% (gray) to 100% (full color). Lightness ranges from 0% (black) to 100% (white), with 50% being the pure color. HSL is far more intuitive for design tasks: to create a lighter version of a color, increase lightness; to desaturate it, reduce saturation. HEX is simply a different notation for RGB — #ff0000 is the same as rgb(255, 0, 0), with each pair of hex digits representing one channel (R, G, B) in base 16.

02

Choosing Color Formats in CSS

Modern CSS supports all three color formats interchangeably, but each has contexts where it is the best choice. Understanding the trade-offs helps you write more maintainable stylesheets.

When to Use HEX, rgb(), and hsl()

HEX (#rrggbb) is the most compact notation and universally supported — use it for static color values copied from design tools like Figma or Sketch, which export in HEX by default. The rgb() function is useful when you need to compute or interpolate color channel values in JavaScript or CSS calc(). The hsl() function is the best choice when you want to define color variations programmatically — for example, creating a button hover state by incrementing lightness by 10%, or generating a palette of tints and shades from a single hue. CSS custom properties (variables) work with all three formats: --brand-color: hsl(220, 90%, 50%).

CSS Custom Properties and Accessibility Considerations

Defining colors as CSS custom properties (--color-primary: #1a73e8) centralizes your color palette and makes global updates a one-line change. For dark mode support, redefine the same custom properties inside a @media (prefers-color-scheme: dark) block or a [data-theme="dark"] selector. For accessibility, the WCAG 2.1 standard requires a minimum contrast ratio of 4.5:1 between text and background for normal text (3:1 for large text). Use HSL to quickly adjust lightness for contrast — if foreground and background have the same hue, adjusting lightness is the most direct path to meeting contrast requirements. Always verify contrast ratios with a dedicated accessibility checker.

FAQ

Can I enter a color without the # prefix for HEX?
Yes. The tool accepts both #ff0000 and ff0000 as valid HEX input.
What is the difference between RGB and HSL?
RGB defines colors by red, green, and blue channel intensity. HSL uses hue (0–360°), saturation (%), and lightness (%), which is often more intuitive for designers.
Does it support alpha / opacity values?
This tool converts opaque colors. For RGBA and HSLA with transparency, additional tools may be needed.
What is the difference between HSL and HSB/HSV?
HSL (Hue, Saturation, Lightness) and HSB/HSV (Hue, Saturation, Brightness/Value) are both cylindrical color models but differ in their third component. In HSL, 50% lightness is a "pure" color (neither tinted white nor shaded black). In HSB/HSV, 100% brightness with 100% saturation is the pure color. CSS uses HSL. Design tools like Photoshop often use HSB. The conversion formulas differ, so be careful when transferring values between CSS and design software.
What does the alpha channel in RGBA/HSLA represent?
The alpha channel (the "A" in RGBA and HSLA) controls transparency. A value of 1 (or 100%) means fully opaque. A value of 0 means fully transparent. Values between 0 and 1 make the element semi-transparent, allowing the background to show through. In CSS, you can write rgba(0, 0, 255, 0.5) for 50% transparent blue, or use the 8-digit HEX format #0000FF80 (where the last two hex digits are the alpha value).

Found a bug or something not working as expected?

Report a bug →