๐ŸŽจ

Color Converter

Convert between HEX, RGB, HSL and more. Pick colors visually.

var(--primary)
๐Ÿ”ท HEX
๐ŸŒˆ RGB
R 139
G 92
B 246
๐ŸŽญ HSL
H 258ยฐ
S 90%
L 66%
๐ŸŽจ Color Harmonies
๐Ÿ’พ Saved Colors

Click on the preview to save colors

๐Ÿ“ CSS Output
color: var(--primary);
background: rgb(139, 92, 246);
border-color: hsl(258, 90%, 66%);
๐ŸŽจ Popular Colors

๐Ÿ“– Complete Guide to Color Formats

Colors are the foundation of visual design, and understanding how they're represented digitally is essential for anyone working in web development, graphic design, or digital media. Different color formats exist because they serve different purposes โ€“ some are human-readable, others are optimized for specific use cases, and each has its strengths and ideal applications.

Understanding HEX Colors

HEX (hexadecimal) is the most widely used color format in web design. It represents colors using a six-character code preceded by a hash symbol (#). The six characters are actually three pairs: the first pair represents red, the second green, and the third blue โ€“ each ranging from 00 (none) to FF (maximum).

  • Format: #RRGGBB (e.g., #FF5733)
  • Range: Each channel 00-FF (0-255 in decimal)
  • Total colors: 16,777,216 possible combinations
  • Common use: CSS, HTML, design software, brand guidelines

HEX colors can also include alpha (transparency) as an eighth character (#RRGGBBAA), though this format has slightly less browser support than other transparency methods.

Understanding RGB Colors

RGB (Red, Green, Blue) represents colors using three decimal values from 0 to 255, one for each primary color of light. This format directly corresponds to how computer displays work โ€“ each pixel contains red, green, and blue sub-pixels that combine to create colors.

  • Format: rgb(R, G, B) (e.g., rgb(255, 87, 51))
  • With transparency: rgba(R, G, B, A) where A is 0-1 (e.g., rgba(255, 87, 51, 0.5))
  • Range: Each channel 0-255
  • Common use: CSS, programming, color manipulation

RGB is intuitive for understanding how colors mix: red + green = yellow, red + blue = magenta, and all three at maximum = white.

Understanding HSL Colors

HSL (Hue, Saturation, Lightness) represents colors in a way that's more intuitive for human perception and color manipulation. Instead of thinking in terms of mixing red, green, and blue light, you think about the color itself, its vibrancy, and its brightness.

  • Hue (H): The color angle on the color wheel (0-360ยฐ). 0ยฐ is red, 120ยฐ is green, 240ยฐ is blue.
  • Saturation (S): The color's intensity or purity (0-100%). 0% is gray, 100% is fully vivid.
  • Lightness (L): How light or dark the color is (0-100%). 0% is black, 50% is pure color, 100% is white.
  • Format: hsl(H, S%, L%) (e.g., hsl(14, 100%, 60%))
  • With transparency: hsla(H, S%, L%, A)

HSL is particularly powerful for creating color variations. Keep the hue constant and adjust saturation and lightness to create harmonious shades, tints, and tones of any color.

๐Ÿ’ก Pro Tip: Use HSL when you need to create color variations or themes! Keep the same hue, increase saturation for more vibrant colors, decrease for muted tones. Adjust lightness to create lighter (tints) or darker (shades) versions of your base color.

Color Theory Basics

Understanding color relationships helps you create visually appealing designs:

The Color Wheel

The color wheel arranges colors in a circle based on their hue. Primary colors (red, yellow, blue in traditional theory; red, green, blue in additive light) are evenly spaced, with secondary and tertiary colors filling the gaps.

Color Harmonies

  • Complementary: Colors opposite on the wheel (180ยฐ apart). High contrast, vibrant combinations (e.g., blue and orange).
  • Analogous: Colors adjacent on the wheel (within 30-60ยฐ). Harmonious, low-contrast, naturally pleasing (e.g., blue, blue-green, green).
  • Triadic: Three colors evenly spaced (120ยฐ apart). Balanced, vibrant, versatile (e.g., red, yellow, blue).
  • Split-Complementary: A color plus two colors adjacent to its complement. Less tension than complementary, still vibrant.
  • Tetradic: Four colors forming a rectangle on the wheel. Rich color schemes requiring careful balance.

Practical Applications

Web Design

For CSS, any format works, but each has advantages: HEX is compact and universally supported, RGB/RGBA is intuitive for programmatic manipulation, and HSL/HSLA is ideal for creating themed color systems with consistent relationships.

Brand Guidelines

Brand documentation typically includes HEX codes for digital use, RGB values for screen applications, CMYK for print (a different color model), and sometimes Pantone codes for precise color matching.

Accessibility

Color choice affects accessibility. WCAG guidelines require minimum contrast ratios between text and background: 4.5:1 for normal text, 3:1 for large text. Tools that check contrast often work with any color format but display results consistently.

Converting Between Formats

Our converter handles all translations automatically, but understanding the math helps:

  • HEX to RGB: Convert each pair from hexadecimal to decimal.
  • RGB to HEX: Convert each decimal value to two-digit hexadecimal.
  • RGB to HSL: Requires calculating the maximum and minimum RGB values, then deriving hue, saturation, and lightness through formulas.
  • HSL to RGB: Uses the hue to determine the base color, then applies saturation and lightness adjustments.

These conversions are mathematically precise โ€“ a color in one format converted to another and back will return the original value (within rounding precision).