Color Converter
Free online color converter. Convert between HEX, RGB, and HSL color formats. Includes color picker, palette generator, and visual preview.
Supports HEX, RGB, RGBA, HSL, HSLA formats
Color Formats Explained
- HEX: Hexadecimal representation (#RRGGBB)
- RGB: Red, Green, Blue values (0-255 each)
- HSL: Hue (0-360°), Saturation (0-100%), Lightness (0-100%)
Converting colors accurately is essential for consistent UI implementation across design files, CSS, and code-driven themes. This tool converts between HEX, RGB, and HSL instantly so you can move from design intent to production values without manual math. For CSS delivery workflows, run final styles through CSS Minifier after you settle color tokens. If you want to understand why HEX values map the way they do, Number Base Converter helps explain the base-16 foundation behind channel conversion.
How to Use
- Enter a color value in HEX, RGB, or HSL.
- Review synchronized conversions across all formats.
- Fine-tune with the color picker and slider controls.
- Generate palette variants for complementary or analogous schemes.
- Copy final values into CSS variables, component themes, or design tokens.
Use one canonical source color per token and derive variants consistently. This reduces drift between product surfaces and keeps component libraries easier to maintain.
Features
Color Formats
HEX (Hexadecimal)
The most common format in web development. Uses 6 hexadecimal digits representing RGB values.
color: #3B82F6;
background: #1F2937;
RGB (Red, Green, Blue)
Specifies colors using red, green, and blue channels from 0-255.
color: rgb(59, 130, 246);
background: rgba(59, 130, 246, 0.5); /* with alpha */
HSL (Hue, Saturation, Lightness)
Represents colors using a more intuitive model:
- Hue: Color wheel position (0-360°)
- Saturation: Color intensity (0-100%)
- Lightness: Brightness (0-100%)
color: hsl(217, 91%, 60%);
background: hsla(217, 91%, 60%, 0.5); /* with alpha */
Live Color Preview
See your color in real-time with automatic contrast text for visibility.
Format Conversion
Enter any format and get all three conversions instantly:
- HEX → RGB → HSL
- RGB → HEX → HSL
- HSL → HEX → RGB
Color Picker
Use the native color picker for visual selection, or fine-tune with RGB sliders.
Palette Generator
Generate harmonious color palettes:
- Complementary: Opposite on the color wheel
- Triadic: Three evenly spaced colors
- Analogous: Adjacent colors
- Split Complementary: Base + two adjacent to complement
Use Cases
Design Systems and Theme Tokens
Define semantic tokens once, then convert and distribute values across CSS custom properties, utility classes, and documentation.
Frontend Component Styling
Use HSL for state variants (hover, active, disabled), then export HEX or RGB values for implementation and compatibility.
Accessibility Reviews
Adjust lightness and saturation while preserving hue families to improve contrast and maintain brand coherence.
Build and Optimization Pipelines
After selecting final values, compress production CSS with CSS Minifier. For deeper understanding of hex channels, reference Number Base Converter.
Technical Details
HEX is base-16 shorthand for RGB channels: each pair maps to one color channel from 00 to FF (0 to 255). RGB is direct channel intensity and is widely used in rendering APIs and canvas operations. HSL is a perceptual editing model that separates hue from saturation and lightness, making iterative design changes more controllable.
In UI engineering, HSL often improves maintainability for variant generation, while HEX remains common for static tokens and interoperability with design tooling. Regardless of format, accessibility depends on contrast and context, not notation. Validate final foreground/background pairs with WCAG contrast checks.
Why Use Different Formats?
| Format | Best For |
|---|---|
| HEX | CSS shorthand, design tools |
| RGB | JavaScript manipulation, animations |
| HSL | Adjusting brightness/saturation, creating themes |
HSL Advantages
HSL is particularly useful for:
- Creating lighter/darker shades by adjusting L
- Desaturating colors by lowering S
- Creating color themes with consistent saturation/lightness
/* Creating a hover effect */
.button {
background: hsl(217, 91%, 60%);
}
.button:hover {
background: hsl(217, 91%, 50%); /* Just darken */
}
Color Theory Basics
The Color Wheel
The color wheel arranges hues in a circle:
- 0°/360°: Red
- 60°: Yellow
- 120°: Green
- 180°: Cyan
- 240°: Blue
- 300°: Magenta
Color Harmonies
Complementary Colors: Colors opposite each other (e.g., blue & orange). High contrast, vibrant.
Triadic Colors: Three colors equally spaced (120° apart). Balanced, colorful.
Analogous Colors: Adjacent colors (30° apart). Harmonious, low contrast.
Split Complementary: Base color + two adjacent to its complement. Less tension than complementary.
Common Conversions
| Color | HEX | RGB | HSL |
|---|---|---|---|
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) |
| Green | #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) |
| Blue | #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) |
| White | #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) |
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) |
Usage in Code
CSS Variables
:root {
--primary: #3B82F6;
--primary-rgb: 59, 130, 246;
--primary-hsl: 217, 91%, 60%;
}
.card {
background: rgba(var(--primary-rgb), 0.1);
}
JavaScript Manipulation
// Parse HEX to RGB
const hexToRgb = hex => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
};
Tailwind CSS
<div class="bg-[#3B82F6] text-white">
Custom color in Tailwind
</div>
FAQ
What is the difference between HEX, RGB, and HSL?
They represent the same color using different models. HEX is compact for code, RGB is channel-based for rendering, and HSL is often easier for hue and lightness adjustments.
When should I use HSL instead of RGB?
Use HSL when you frequently adjust brightness or saturation for theming, hover states, and design systems. It is more intuitive for controlled color variation.
Can I use 3-digit HEX shorthand safely?
Yes, when each RGB pair uses repeated digits. For example, #F0A expands to #FF00AA. Otherwise use full 6-digit HEX.
How does this relate to number-base conversion?
HEX is base-16 notation. Converting channel values between decimal and hexadecimal is a core part of moving between RGB and HEX formats.
Privacy Note
All color conversion and palette calculations run locally in your browser. Your color inputs are not transmitted to a remote server by default.
Related Tools
CSS Minifier & Beautifier
Free online CSS minifier and beautifier. Compress CSS to reduce file size or format for readability. View statistics and color palette extraction.
Number Base Converter
Free online number base converter. Convert between binary, octal, decimal, and hexadecimal instantly with bit information.