Use Cases
- CSS color conversion - Switch between hex, rgb(), hsl() for stylesheets
- Design handoff - Convert designer hex codes to RGB for programming
- Color manipulation - Adjust hue, saturation, lightness in HSL/HSV
- Accessibility - Convert colors to check contrast ratios
- Theme generation - Create color palettes in different formats
- Cross-platform development - Use RGB for Android, hex for iOS/web
Supported Formats
HEX (Hexadecimal)
- 3-digit:
#f00(shorthand for#ff0000) - 4-digit:
#f00a(with alpha) - 6-digit:
#ff0000(standard) - 8-digit:
#ff0000aa(with alpha)
RGB/RGBA (Red, Green, Blue, Alpha)
rgb(255, 0, 0)(opaque red)rgba(255, 0, 0, 0.5)(50% transparent red)
HSL/HSLA (Hue, Saturation, Lightness, Alpha)
hsl(0, 100%, 50%)(pure red)hsla(0, 100%, 50%, 0.5)(50% transparent red)
HSV/HSVA (Hue, Saturation, Value, Alpha)
hsv(0, 100%, 100%)(pure red)hsva(0, 100%, 100%, 0.5)(50% transparent red)
The tool automatically handles alpha (transparency) values. If alpha is 1.0 (fully opaque), the output uses 3/6-digit hex and rgb/hsl/hsv notation. If alpha < 1.0, it outputs 8-digit hex and rgba/hsla/hsva notation.
Input Format
Paste any of these formats:Output Format
Default (All Formats)
Shows all conversions plus CSS variable examples:Action-Specific Outputs
- to-hex:
#ff0000or#ff0000aa(with alpha) - to-rgb:
rgb(255, 0, 0)orrgba(255, 0, 0, 0.5) - to-hsl:
hsl(0, 100%, 50%)orhsla(0, 100%, 50%, 0.5) - to-hsv:
hsv(0, 100%, 100%)orhsva(0, 100%, 100%, 0.5)
Examples
Technical Details
Located in
lib/tools/engine.ts:823-901Parsing Input
- Hex detection: Regex
#?([0-9a-f]{3,8}) - RGB detection: Regex
rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\) - HSL detection: Regex
hsla?\(([\d.]+),\s*([\d.]+)%?,\s*([\d.]+)%?(?:,\s*([\d.]+))?\)
Color Space Conversion Algorithms
HSL to RGB
Uses the standard hue-to-RGB algorithm:RGB to HSL
RGB to HSV
Alpha Channel Handling
- Opaque (alpha = 1.0): Outputs standard formats
- Transparent (alpha < 1.0): Adds alpha to all formats
- 8-digit hex: Alpha is in range 00-FF (0-255)
Understanding Color Spaces
RGB (Additive Color)
- Range: R, G, B each 0-255
- Use case: Screens, monitors, digital images
- Example:
rgb(255, 0, 0)= pure red (all red, no green/blue)
HSL (Human-Friendly)
- Hue (0-360°): Color wheel position (0=red, 120=green, 240=blue)
- Saturation (0-100%): Color intensity (0=gray, 100=pure color)
- Lightness (0-100%): Brightness (0=black, 50=normal, 100=white)
- Use case: Adjusting colors (“make it lighter”, “less saturated”)
HSV (Artist-Friendly)
- Hue (0-360°): Same as HSL
- Saturation (0-100%): Color purity (0=white, 100=pure color)
- Value (0-100%): Brightness (0=black, 100=bright)
- Use case: Color pickers, painting applications
HSL vs HSV: Both use the same hue wheel, but differ in how they represent saturation and brightness. HSL’s lightness goes from black → color → white. HSV’s value goes from black → color (no white endpoint).
CSS Variable Output
The tool generates ready-to-use CSS custom properties:Common Patterns
Lightening a Color
- Convert to HSL:
hsl(204, 70%, 53%) - Increase lightness:
hsl(204, 70%, 73%)(+20%) - Convert back to hex:
#72b3e6
Desaturating a Color
- Convert to HSL:
hsl(0, 100%, 50%) - Reduce saturation:
hsl(0, 50%, 50%)(50% sat) - Convert back:
#bf4040(muted red)
Adjusting Opacity
- Convert to RGBA:
rgba(255, 0, 0, 1.0) - Change alpha:
rgba(255, 0, 0, 0.5) - Convert to 8-digit hex:
#ff000080
Color Palettes
Generate shades by adjusting HSL lightness:Related Tools
- Number Base Converter - Convert hex to decimal (for color components)
- SVG to CSS - Embed SVG with color codes in CSS
- CSS Beautify/Minify - Format CSS with color values