Color Converter

Convert colors between HEX, RGB, HSL and HSV formats with a visual color picker

Try an example

Click swatch to open color picker

Or edit any value below

HEX
RGB
HSL
HSV

What Is Color Conversion?

A color converter translates a color value from one notation to another β€” for example, from a HEX triplet (#6366F1) to an RGB tuple (99, 102, 241) or an HSL triple (239, 84%, 67%). A single color can also be expressed as an HSV triple (239, 59%, 95%). Each format encodes the same visual color using a different mathematical model; different tools, languages, and APIs all expect different formats depending on context.

HEX and RGB both describe color as a mix of red, green, and blue light. HEX is a compact hexadecimal representation of the same three 0-255 channel values that RGB spells out in decimal. HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value) rearrange the same information into a cylindrical coordinate system where hue is an angle on a color wheel (0-360 degrees), and saturation and lightness or brightness are percentages. This makes HSL and HSV more intuitive for tasks like creating lighter or darker shades of the same hue.

Converting between these formats requires well-defined math. The W3C CSS Color Module Level 4 specification documents the algorithms browsers use to resolve any CSS color into an sRGB triplet. The formulas are deterministic: a given input always produces the same output, so conversions are lossless as long as the values are not rounded or clamped. Most color pickers and design tools rely on these same formulas under the hood.

Why Use This Color Converter?

Design tools export colors in one format, your CSS needs another, and the API you are calling expects a third. Instead of writing conversion code or searching for the right formula, paste a value and get every format at once.

⚑
Instant Live Conversion
Type or pick a color and see HEX, RGB, HSL, and HSV update in real time. No submit button, no round-trip to a server.
πŸ”’
Privacy-first Processing
All conversion math runs in your browser. No color values, no usage data, and no cookies are sent anywhere.
πŸ”€
All Four Formats at Once
One input produces HEX, RGB, HSL, and HSV simultaneously. Copy whichever format you need with a single click.
πŸ“‹
No Account Required
Open the page and start converting. No sign-up, no email, no rate limits. Works offline once loaded.

Color Converter Use Cases

CSS Development
A designer hands you a HEX value from Figma, but your component library uses HSL for theming. Convert the value and drop it into your CSS custom properties or Tailwind config.
Backend API Integration
Your endpoint accepts colors as RGB arrays for chart generation. Convert the brand HEX codes from the style guide into the integer triplets the API expects.
Design System Maintenance
When documenting a design system, you need every color token listed in HEX for quick reference, RGB for Canvas rendering, and HSL for programmatic shade generation.
QA and Visual Testing
Comparing a screenshot's pixel color (usually reported in RGB by browser DevTools) against the expected HEX value from a Figma spec. Quick conversion confirms or flags mismatches.
Data Visualization
Chart libraries like D3.js and Chart.js accept colors in different formats depending on the method. Convert once and keep a consistent notation across your dataset configuration.
Learning Color Theory
Students studying computer graphics or web design can see how the same color maps across HEX, RGB, HSL, and HSV. Adjusting one channel and watching the others change builds intuition for how color models relate.

Color Format Reference

The table below lists the five most common color formats, with the same indigo color (#6366F1) shown in each notation. HEX and RGB are the most widely supported in CSS and JavaScript. HSL is preferred for theming because adjusting lightness and saturation is straightforward. HSV is the model used by most graphic design software color pickers.

FormatExample (indigo)ChannelsCommon usage
HEX#6366F16 (or 3/8)CSS, design tools, brand guides
RGBrgb(99, 102, 241)3 (0–255 each)CSS, Canvas API, image processing
HSLhsl(239, 84%, 67%)3 (deg, %, %)CSS, color theming, accessibility tuning
HSVhsv(239, 59%, 95%)3 (deg, %, %)Color pickers, Photoshop, Figma
CMYKcmyk(59%, 58%, 0%, 5%)4 (0–100% each)Print design, prepress workflows

HEX vs RGB vs HSL

All three formats describe the same sRGB color space. The difference is how they expose the data, which affects readability and ease of manipulation in different contexts.

HEX
A 6-digit hexadecimal string (or 3-digit shorthand). Compact and universal in CSS, design tools, and brand guidelines. Hard to read at a glance: #6366F1 does not tell you the hue. Supports an optional 8-digit form (#6366F180) for alpha transparency.
RGB
Three integers from 0 to 255 for red, green, and blue channels. The native format for Canvas 2D, WebGL, and most image processing libraries. Easy to manipulate channel by channel, but adjusting perceived brightness requires changing all three values together.
HSL
Hue (0-360 degrees), saturation (0-100%), and lightness (0-100%). Designed for human readability. To make a color lighter, increase L. To desaturate, decrease S. CSS natively supports hsl() notation, and modern CSS color-mix() and relative color syntax build on it.

Code Examples

Color conversion between HEX, RGB, and HSL in common languages and environments. Each example uses the same indigo color (#6366F1) for easy comparison.

JavaScript
// HEX β†’ RGB
function hexToRgb(hex) {
  const n = parseInt(hex.replace('#', ''), 16)
  return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
}
hexToRgb('#6366f1') // β†’ [99, 102, 241]

// RGB β†’ HSL
function rgbToHsl(r, g, b) {
  r /= 255; g /= 255; b /= 255
  const max = Math.max(r, g, b), min = Math.min(r, g, b)
  const l = (max + min) / 2
  if (max === min) return [0, 0, Math.round(l * 100)]
  const d = max - min
  const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
  let h = 0
  if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6
  else if (max === g) h = ((b - r) / d + 2) / 6
  else h = ((r - g) / d + 4) / 6
  return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)]
}
rgbToHsl(99, 102, 241) // β†’ [239, 84, 67]
Python
import colorsys

# HEX β†’ RGB
def hex_to_rgb(hex_str: str) -> tuple[int, int, int]:
    h = hex_str.lstrip('#')
    return tuple(int(h[i:i+2], 16) for i in (0, 2, 4))

hex_to_rgb('#6366f1')  # β†’ (99, 102, 241)

# RGB β†’ HSL (colorsys uses HLS order)
r, g, b = 99 / 255, 102 / 255, 241 / 255
h, l, s = colorsys.rgb_to_hls(r, g, b)
print(f"hsl({h * 360:.0f}, {s * 100:.0f}%, {l * 100:.0f}%)")
# β†’ hsl(239, 84%, 67%)

# RGB β†’ HSV
h, s, v = colorsys.rgb_to_hsv(r, g, b)
print(f"hsv({h * 360:.0f}, {s * 100:.0f}%, {v * 100:.0f}%)")
# β†’ hsv(239, 59%, 95%)
Go
package main

import (
	"fmt"
	"math"
)

func hexToRGB(hex string) (int, int, int) {
	var r, g, b int
	fmt.Sscanf(hex, "#%02x%02x%02x", &r, &g, &b)
	return r, g, b
}

func rgbToHSL(r, g, b int) (int, int, int) {
	rf, gf, bf := float64(r)/255, float64(g)/255, float64(b)/255
	max := math.Max(rf, math.Max(gf, bf))
	min := math.Min(rf, math.Min(gf, bf))
	l := (max + min) / 2
	if max == min {
		return 0, 0, int(math.Round(l * 100))
	}
	d := max - min
	s := d / (2 - max - min)
	if l <= 0.5 {
		s = d / (max + min)
	}
	var h float64
	switch max {
	case rf: h = (gf - bf) / d; if gf < bf { h += 6 }
	case gf: h = (bf - rf) / d + 2
	case bf: h = (rf - gf) / d + 4
	}
	return int(math.Round(h / 6 * 360)), int(math.Round(s * 100)), int(math.Round(l * 100))
}

func main() {
	r, g, b := hexToRGB("#6366f1")
	fmt.Println(r, g, b)         // β†’ 99 102 241
	fmt.Println(rgbToHSL(r, g, b)) // β†’ 239 84 67
}
CSS
/* Modern CSS supports multiple color formats natively */

/* HEX notation */
.button { color: #6366f1; }

/* RGB functional notation */
.button { color: rgb(99 102 241); }

/* HSL β€” easier to adjust lightness and saturation */
.button { color: hsl(239 84% 67%); }

/* CSS Color Level 4: relative color syntax (Chrome 119+) */
.button-light { color: hsl(from #6366f1 h s calc(l + 20%)); }

/* color-mix() for tinting without manual conversion */
.button-muted { color: color-mix(in srgb, #6366f1 70%, white); }

Frequently Asked Questions

What is the difference between HSL and HSV?
Both use hue and saturation, but they define brightness differently. HSL uses lightness, where 50% is the pure color, 0% is black, and 100% is white. HSV uses value (or brightness), where 100% is the pure color and 0% is black. HSV does not have a direct white endpoint. In practice, HSL is used in CSS and web development, while HSV is the model behind most color pickers in design software like Photoshop and Figma.
How do I convert HEX to RGB in JavaScript?
Parse the hex string into an integer with parseInt(hex, 16), then extract each channel with bit shifting: (n >> 16) & 255 for red, (n >> 8) & 255 for green, and n & 255 for blue. This handles any 6-digit hex string with or without the leading # sign. For 3-digit shorthand like #F0F, expand each digit first (FF00FF) before parsing.
Can I use HSL directly in CSS?
Yes. All modern browsers support hsl() and hsla() in CSS. As of CSS Color Level 4, the syntax is hsl(239 84% 67%) with space-separated values (commas are still accepted). You can also add alpha as a fourth parameter: hsl(239 84% 67% / 0.5). Safari, Chrome, Firefox, and Edge all support this syntax.
Is color conversion lossy?
Mathematically, no. HEX, RGB, HSL, and HSV all describe the same sRGB color space and the conversions are reversible. In practice, small rounding differences can appear because HEX is limited to 256 steps per channel and HSL percentages are typically rounded to integers. Converting back and forth multiple times can accumulate rounding errors of 1-2 units.
What is the 8-digit HEX format?
The 8-digit HEX format adds two alpha (transparency) digits to the standard 6-digit HEX color. For example, #6366F180 means the same indigo color at 50% opacity (0x80 = 128, roughly 50% of 255). CSS supports this notation in all modern browsers. The short form is 4 digits, like #63F8.
Why does my color look different on another monitor?
Color appearance depends on the monitor's color profile, brightness, and gamma calibration. Two screens can display the same sRGB value (#6366F1) differently if their color profiles diverge. Color conversion tools work in a defined color space (usually sRGB) and produce mathematically correct output. Perceived differences are a display calibration issue, not a conversion error.
How do I pick a lighter or darker shade of a color?
Convert the color to HSL and adjust the L (lightness) channel. Increasing L toward 100% produces lighter tints; decreasing it toward 0% produces darker shades. The hue and saturation stay the same. In CSS, you can do this directly: hsl(239 84% 80%) is a lighter version of hsl(239 84% 67%). Modern CSS also offers color-mix(in srgb, #6366F1, white 30%) for the same effect without manual conversion.