Color Converter
Convert colors between HEX, RGB, and HSL with live preview, contrast checking, and quick-copy formats for your design system.
Design ToolsHow to Use Color Converter
What is a Color Converter?
A color converter is an essential design tool that translates color values between different color models: HEX (hexadecimal), RGB (red-green-blue), and HSL (hue-saturation-lightness). Each format has its own strengths and use cases in design and development workflows.
This tool provides instant bidirectional conversion with live preview, accessibility contrast checking, and a swatch system for building and managing color palettes.
Why Use a Color Converter?
Converting between color formats is crucial for modern design and development:
- Cross-format compatibility: Design tools use HEX, CSS supports RGB/HSL, and color theory works best with HSL
- Design systems: Maintain consistent colors across different platforms and formats
- Accessibility: Check contrast ratios to ensure WCAG compliance
- Color manipulation: HSL makes it easier to adjust lightness/saturation without changing hue
- Developer handoff: Provide colors in the exact format developers need
- Brand consistency: Save and reuse brand colors across projects
Understanding Color Formats
HEX (Hexadecimal)
The most common web color format, using 6 characters to represent RGB values.
Format: #RRGGBB
- Each pair represents Red, Green, Blue (00-FF in hexadecimal)
- Example:
#6366F1(indigo),#EF4444(red),#FFFFFF(white)
When to use HEX:
- Web design and HTML/CSS
- Design tools (Figma, Sketch, Adobe XD)
- Sharing colors in documentation
- Most compact format for digital use
Shorthand: 3-character HEX like #FFF expands to #FFFFFF
RGB (Red-Green-Blue)
Additive color model using three channels, each from 0-255.
Format: rgb(r, g, b)
- R: Red channel (0-255)
- G: Green channel (0-255)
- B: Blue channel (0-255)
- Example:
rgb(99, 102, 241)(indigo),rgb(239, 68, 68)(red)
When to use RGB:
- CSS styling (especially with alpha:
rgba()) - JavaScript color manipulation
- Image processing and canvas operations
- When you need to adjust individual color channels
- Working with lighting and screen displays
Advantages: Easy to understand, directly maps to screen pixel values, widely supported.
HSL (Hue-Saturation-Lightness)
Human-friendly color model based on color perception.
Format: hsl(h, s%, l%)
- H: Hue (0-360 degrees on color wheel)
- 0°/360° = Red
- 120° = Green
- 240° = Blue
- S: Saturation (0-100%, 0% = grayscale, 100% = fully saturated)
- L: Lightness (0-100%, 0% = black, 50% = pure color, 100% = white)
- Example:
hsl(239, 84%, 67%)(indigo)
When to use HSL:
- Creating color variations (lighter/darker shades)
- Building color palettes with consistent saturation
- Adjusting colors intuitively (hue for color, saturation for intensity, lightness for brightness)
- Animations and transitions between colors
- Generating accessible color combinations
Advantages: Most intuitive for designers, easy to create color schemes, perfect for programmatic color generation.
How to Use This Tool
Quick Start (30 seconds)
- Enter a color in any format (HEX, RGB, or HSL)
- See instant conversion to all three formats in the preview
- Check contrast against white and black backgrounds
- Click copy button next to any format to copy it
- Add to swatches to save colors for later use
Color Input Methods
HEX Input
Accepted formats:
- Full 6-character:
#6366F1or6366F1 - Short 3-character:
#F00orF00(expands to#FF0000) - With or without
#symbol
Tips:
- Tool automatically normalizes to uppercase 6-character format
- Invalid HEX shows no change until corrected
- Copy button gives you ready-to-use
#RRGGBBformat
RGB Input
Three separate fields for Red, Green, Blue:
- Each channel: 0-255
- Values automatically clamped to valid range
- Live preview updates as you type
Use cases:
- Fine-tune individual color channels
- Match specific RGB values from design specs
- Create grayscale colors (R=G=B)
HSL Input
Three separate fields for Hue, Saturation, Lightness:
- Hue: 0-360 (wraps around)
- Saturation: 0-100%
- Lightness: 0-100%
Tips:
- Adjust Hue to change color while keeping intensity
- Reduce Saturation for muted/pastel colors
- Increase Lightness for tints, decrease for shades
- HSL is perfect for creating color variations
Live Preview
The large color swatch shows your current color in real-time.
Preview displays:
- Main color block (large)
- All three format representations
- Current HEX, RGB, and HSL values side-by-side
Real-time updates: Any change to any format instantly updates the preview and all other formats.
Contrast Checking
Built-in WCAG contrast ratio checker helps ensure your colors are accessible.
Two contrast checks:
- On white background: Shows contrast ratio of your color against white (#FFFFFF)
- On black background: Shows contrast ratio of your color against black (#000000)
Ratings:
- OK (Green): Contrast ratio ≥ 4.5:1 (WCAG AA standard for normal text)
- Low (Amber): Contrast ratio < 4.5:1 (may not meet accessibility standards)
WCAG Guidelines:
- Normal text: 4.5:1 minimum (AA), 7:1 enhanced (AAA)
- Large text (18pt+): 3:1 minimum (AA), 4.5:1 enhanced (AAA)
- UI components: 3:1 minimum
Use cases:
- Choosing text colors for light/dark themes
- Ensuring button colors have sufficient contrast
- Validating brand colors meet accessibility standards
- Creating inclusive designs for users with visual impairments
Quick Copy Actions
Copy any format with one click:
-
Copy HEX: Copies
#RRGGBBformat- Perfect for design tools and HTML
- Example:
#6366F1
-
Copy RGB: Copies
rgb(r, g, b)CSS format- Ready to paste into CSS/SCSS
- Example:
rgb(99, 102, 241)
-
Copy HSL: Copies
hsl(h, s%, l%)CSS format- Perfect for CSS with HSL syntax
- Example:
hsl(239, 84%, 67%)
Feedback: A checkmark appears next to the copied format for 1.8 seconds, and a toast notification confirms the copy.
Color Swatches System
Save colors to build and manage palettes:
Add to Swatches
Click "Add current" to save the current color to your swatch library.
- Prevents duplicates automatically
- Unlimited swatch storage (per session)
- Perfect for brand color palettes
Using Swatches
Click any saved swatch to:
- Instantly load that color
- Update all format fields
- See contrast checks for that color
Each swatch shows:
- Small color preview circle
- HEX code for quick reference
Clear Swatches
Click "Clear" to remove all saved swatches.
- Useful when starting a new project
- Does not affect current color
Use cases:
- Building brand color palettes
- Saving variations of a base color
- Quick access to frequently used colors
- Comparing multiple color options
- Exporting color schemes (copy each HEX)
Reset Function
Click "Reset" to return to the default color (indigo #6366F1).
- Useful when experimenting goes wrong
- Quick way to start fresh
- Does not clear swatches
Common Use Cases
Brand Color Documentation
Convert your brand colors to all formats for design system documentation.
Workflow:
- Enter your brand HEX color
- Copy RGB and HSL values
- Add to swatches
- Check contrast for accessibility
- Document all three formats in your style guide
Creating Color Variations
Use HSL to generate tints and shades of your base color.
Example - Generating a blue palette:
- Start with base blue:
hsl(220, 90%, 56%) - Lighter tint: Keep H and S, increase L to 70%
- Darker shade: Keep H and S, decrease L to 40%
- Muted version: Keep H and L, decrease S to 50%
- Add all variations to swatches
Design Tool to CSS Workflow
Convert colors from design tools (which use HEX) to CSS-friendly formats.
- Copy HEX from Figma/Sketch
- Paste into HEX input
- Copy RGB or HSL for CSS
- Use in your stylesheets
Accessibility Compliance
Ensure text colors meet WCAG standards.
Example - Checking button colors:
- Enter button background color
- Check contrast on white (for dark buttons)
- Check contrast on black (for light buttons)
- Aim for 4.5:1 ratio minimum
- Adjust lightness in HSL if contrast is low
Color Palette Building
Create cohesive color schemes for your project.
Workflow:
- Start with primary brand color
- Adjust hue for complementary colors
- Save each to swatches
- Verify contrast for text on each color
- Export all HEX values for documentation
CSS Custom Properties (Variables)
Generate CSS variable definitions in multiple formats.
Example:
:root {
/* HEX format */
--primary: #6366F1;
/* RGB format (allows alpha channel) */
--primary-rgb: 99, 102, 241;
--primary-alpha: rgba(var(--primary-rgb), 0.8);
/* HSL format (easy manipulation) */
--primary-hsl: 239, 84%, 67%;
--primary-light: hsl(239, 84%, 80%);
}
JavaScript Color Manipulation
Get color values in formats JavaScript understands.
Example - Canvas drawing:
// From RGB format
const color = 'rgb(99, 102, 241)';
ctx.fillStyle = color;
// For individual channel manipulation
const [r, g, b] = [99, 102, 241];
Best Practices
Do's
- Use HEX for static colors: Design files, documentation, HTML color attributes
- Use RGB with alpha: When you need transparency (
rgba(99, 102, 241, 0.5)) - Use HSL for variations: Creating lighter/darker versions, color schemes
- Check contrast: Always verify text colors meet WCAG standards
- Save swatches: Build a library of tested, accessible brand colors
- Document all formats: Provide HEX, RGB, and HSL in style guides
- Use HSL for animations: Smoother transitions between colors
Don'ts
- Don't use low contrast: Colors with < 4.5:1 ratio fail accessibility
- Don't forget alpha: RGB/HSL support alpha (
rgba(),hsla()), HEX needs 8 characters - Don't mix formats randomly: Be consistent within a project or component
- Don't rely on memory: Use swatches to save important colors
- Don't ignore dark mode: Test colors on both light and dark backgrounds
- Don't use pure black:
#000000can be harsh; use dark gray instead
Technical Details
Color Space
All conversions use the sRGB color space, standard for web and digital displays.
Conversion accuracy:
- HEX ↔ RGB: Exact (direct mapping)
- RGB ↔ HSL: High precision with rounding
- Full round-trip conversion maintains color fidelity
Precision
- RGB: Integer values (0-255)
- HSL: H rounded to nearest degree, S/L rounded to nearest percent
- HEX: 256 values per channel (24-bit true color)
Contrast Calculation
Uses WCAG 2.1 relative luminance formula:
- Convert RGB to linear RGB (gamma correction)
- Calculate luminance:
L = 0.2126 * R + 0.7152 * G + 0.0722 * B - Contrast ratio:
(L1 + 0.05) / (L2 + 0.05)where L1 > L2
Browser Compatibility
All formats are universally supported:
- HEX: All browsers, all versions
- RGB/RGBA: All browsers, all versions
- HSL/HSLA: IE9+, all modern browsers
Input Validation
- HEX: Accepts 3 or 6 characters, with or without
#, validates hex digits - RGB: Clamps each channel to 0-255 range
- HSL: Wraps hue to 0-360, clamps S/L to 0-100
- Invalid inputs don't update color until corrected
Keyboard Shortcuts
Enhance productivity with input features:
- Tab: Navigate between input fields
- Arrow Up/Down: Increment/decrement RGB/HSL values (when field is focused)
- Enter in inputs: Updates color and moves to next field
- Cmd/Ctrl + C: Copy when field is focused
Integration with Design Systems
Exporting Color Tokens
Use this tool to generate design tokens:
Example - Design tokens file:
{
"color": {
"primary": {
"hex": "#6366F1",
"rgb": "rgb(99, 102, 241)",
"hsl": "hsl(239, 84%, 67%)"
}
}
}
Sass/SCSS Variables
Generate Sass variables in any format:
// HEX
$primary: #6366F1;
// RGB (for rgba() function)
$primary-rgb: 99, 102, 241;
$primary-alpha: rgba($primary-rgb, 0.8);
// HSL (for color manipulation)
$primary-hsl: 239, 84%, 67%;
$primary-light: hsl(239, 84%, 80%);
Tailwind CSS
Convert colors to Tailwind color palette format:
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#6366F1',
rgb: '99 102 241', // Space-separated for rgb()
}
}
}
}
}
Advanced Techniques
Creating Monochromatic Palettes
Use HSL to generate shades from a base color:
- Start with base color (e.g.,
hsl(220, 90%, 56%)) - Keep H and S constant
- Vary L: 95% (lightest), 70%, 56% (base), 40%, 20% (darkest)
- Save all 5 shades to swatches
Generating Complementary Colors
Use HSL hue wheel:
- Start with base hue (e.g., 220° blue)
- Complementary: Add 180° (= 40° orange)
- Triadic: Add 120° and 240° (140° green, 340° red-violet)
- Analogous: Add/subtract 30° (190°, 250°)
Color Temperature Adjustment
Make colors warmer or cooler:
- Warmer: Shift hue toward red/yellow (increase H if in blue/purple range)
- Cooler: Shift hue toward blue (decrease H if in red/orange range)
- Keep S and L constant for consistency
Accessibility-First Workflow
- Choose base brand color
- Check contrast on white and black
- If Low, adjust L in HSL:
- For dark text on light: Decrease L until contrast ≥ 4.5:1
- For light text on dark: Increase L until contrast ≥ 4.5:1
- Save accessible version to swatches
- Generate lighter (L+20%) and darker (L-20%) variations
Accessibility
Screen Readers
All inputs have proper labels for screen reader users.
Keyboard Navigation
Full keyboard support:
- Tab through all inputs and buttons
- Enter to activate buttons
- Arrow keys in number inputs
Color Vision Deficiency
Contrast checker helps users with:
- Protanopia (red-blind)
- Deuteranopia (green-blind)
- Tritanopia (blue-blind)
High contrast ratios ensure visibility across all types of color vision.
Tips & Tricks
Quick Gray Scale
To create perfect grayscale:
- HEX: Use same value for all channels (
#888888) - RGB: Set R=G=B (e.g.,
rgb(128, 128, 128)) - HSL: Set S=0% (any hue works)
Pure Colors
For fully saturated colors:
- HSL: Set S=100%, L=50%
- Adjust H for different colors (0°=red, 120°=green, 240°=blue)
Pastel Colors
For soft, pastel tones:
- HSL: Set S=30-50%, L=80-90%
- High lightness + low saturation = pastels
Finding Mid-Point Colors
Average two colors:
- Convert both to RGB
- Average each channel:
newR = (r1 + r2) / 2 - Convert back to desired format
Color Harmony Rules
Use HSL for color theory:
- Monochromatic: Same H, vary S and L
- Analogous: H ± 30°, same S and L
- Complementary: H + 180°, same S and L
- Triadic: H, H+120°, H+240°, same S and L
From Converter to Production
Remember:
- Test on real devices: Colors look different on various screens
- Check in context: View colors with actual content, not just swatches
- Verify dark mode: Test light colors on dark backgrounds and vice versa
- Document your palette: Save all brand colors in all three formats
- Use design tokens: Store colors in a single source of truth
- Consider color blindness: Run designs through color blindness simulators
- Test print colors: Screen colors (RGB) differ from print colors (CMYK)
Frequently Asked Questions
Related Creative & Design Tools
HEIC to JPG Converter
Convert HEIC/HEIF images to JPG format with adjustable quality settings. All conversions run locally in your browser - files never leave your device. Perfect for converting iPhone photos to a universally compatible format.
Use Tool →PNG to JPG Converter
Convert PNG images to JPG format with adjustable quality and transparency handling. All conversions run locally in your browser - files never leave your device. Perfect for reducing file sizes while maintaining image quality.
Use Tool →Gradient Generator
Create beautiful CSS and Tailwind gradients with a visual editor. Support for linear and radial gradients with full control over colors, angles, and stops.
Use Tool →Neumorphism Generator
Create beautiful neumorphism (soft UI) CSS effects with live preview. Generate soft, extruded 3D elements with dual shadows. Perfect for modern minimalist designs.
Use Tool →Image Placeholder Generator
Generate clean placeholder images with custom sizes, colors, and labels. Perfect for wireframes, mockups, and design systems.
Use Tool →Box Shadow Generator
Visually design layered box shadows with fine-grained controls. Create production-ready CSS and Tailwind utilities for cards, modals, and UI elevations.
Use Tool →Logo Placeholder Generator
Generate simple placeholder logos with monograms, shapes, and preset color palettes. Perfect for mockups, prototypes, and early-stage branding.
Use Tool →Color Palette Generator
Generate beautiful, harmonious color palettes for UI design, branding, and themes. Choose from random, analogous, complementary, or monochromatic modes. Lock favorite colors and export as HEX, RGB, or JSON.
Use Tool →Share Your Feedback
Help us improve this tool by sharing your experience