Skip to content

Color Converter — HEX, RGB, HSL Online

Convert colors between HEX, RGB, and HSL with live preview — free, instant, and browser-based.

Last updated:

Color Models Explained

Every color you see on screen can be described by multiple mathematical models. Understanding the differences between them is the first step to choosing the right format for your project.

  • HEX is the most common web color notation. A six-character string like #3b82f6 encodes red, green, and blue channels as two hexadecimal digits each. Three-character shorthand such as #fff expands by doubling each digit to #ffffff.
  • RGB represents colors as an additive mix of red, green, and blue light, each ranging from 0 to 255. It maps directly to how monitors emit color, making it the native format for screens and image manipulation libraries.
  • HSL (Hue, Saturation, Lightness) describes color the way humans think about it. Hue is an angle on the color wheel (0-360), saturation is the intensity (0-100%), and lightness controls how bright or dark the color appears (0-100%). This makes it intuitive to create tints, shades, and complementary palettes by adjusting a single value.
  • HSV / HSB (Hue, Saturation, Value / Brightness) is closely related to HSL but defines brightness differently. In HSV, 100% value means the color is fully bright regardless of saturation, which is why most visual color pickers in design tools like Figma, Photoshop, and Sketch use HSV rather than HSL.

When to Use Which Format

Choosing the right color model depends on what you are trying to accomplish. Each format has practical strengths in certain workflows.

  • HEX for CSS and branding. It is compact, universally supported, and easy to paste into stylesheets. Most brand guidelines ship their palette as HEX values.
  • RGB for programmatic manipulation. When you need to blend colors, apply alpha compositing, or manipulate pixel data in a canvas or image library, RGB is the natural choice because the math operates directly on the channel values.
  • HSL for design systems. Need a darker variant of your primary color? Lower the lightness. Want a muted background? Reduce saturation. HSL lets you create coherent palettes by tweaking one axis at a time. Modern CSS supports hsl() natively, making it a great choice for design tokens and theming.
  • HSV for color pickers. If you are building a custom color picker UI or need to match values from Figma or Photoshop, HSV aligns with the way those tools present color selection. Converting to HSV ensures your picker output matches the visual representation.

Common Color Conversion Gotchas

Converting between color models is mostly straightforward, but there are a few pitfalls that regularly trip up developers.

  • Rounding errors. HSL and HSV use percentages and degrees that don't always map to exact integer RGB values. Converting from HSL to RGB and back may shift a value by one unit. This tool rounds to the nearest integer for RGB channels and to one decimal place for HSL/HSV, which is sufficient for CSS but worth noting if you need lossless round-trip fidelity.
  • Alpha channel handling. HEX can include an alpha channel as a fourth byte (e.g. #3b82f680), and CSS supports rgba() and hsla() functions. Not all conversion tools account for alpha, which can silently discard transparency.
  • Shorthand HEX expansion. #fff is equivalent to #ffffff, not #0f0f0f. Each character is doubled, not zero-padded. Similarly, four-digit shorthand like #f008 expands to #ff000088.
  • CSS color function syntax. Modern CSS uses space-separated values with an optional slash for alpha: rgb(59 130 246 / 0.5) instead of the legacy comma-separated rgba(59, 130, 246, 0.5). Both are valid, but mixing them up causes syntax errors.

Color Accessibility and Contrast

Color choice directly affects whether your content is readable. The Web Content Accessibility Guidelines (WCAG) define minimum contrast ratios between foreground text and its background to ensure legibility for users with low vision or color deficiencies.

  • WCAG AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18px+ bold or 24px+ regular). This is the baseline for most compliance requirements.
  • WCAG AAA raises the bar to 7:1 for normal text and 4.5:1 for large text, providing enhanced readability.
  • Lightness is the key lever. Contrast ratio is derived from relative luminance, which is most sensitive to the lightness component. When using HSL, checking the L value gives you a quick approximation: text with L below 40% on a white background typically meets AA, but always verify with a proper contrast checker.
  • Don't rely on color alone. Roughly 8% of men have some form of color vision deficiency. Use shape, pattern, or text labels alongside color to convey meaning. If your UI uses red and green to indicate error and success states, add icons or labels as well.

Converting your brand colors to HSL makes it easier to generate accessible variants. Keep the hue fixed, then adjust saturation and lightness until the contrast ratio meets your target.

Related Tools

If you work with color values regularly, these tools may also be useful:

  • Hex to Decimal Converter — convert any hexadecimal value (including individual color channel bytes) to its decimal equivalent and vice versa.
  • CSS Minifier — after finalizing your color values, minify your stylesheets to reduce file size. The minifier can also convert long-form HEX values to shorthand where possible.
  • HTML Beautifier — reformat inline styles and markup to make color declarations easier to scan and update.

Frequently Asked Questions

What color formats are supported?
HEX (#RRGGBB or #RGB), RGB (rgb(r, g, b) with values 0-255), and HSL (hsl(h, s%, l%) with hue 0-360 and saturation/lightness 0-100%).
What's the difference between RGB and HSL?
RGB defines colors by red, green, and blue light intensity (0-255). HSL defines colors by hue (color wheel angle), saturation (intensity), and lightness (brightness). HSL is often more intuitive for adjusting colors.
Can I enter shorthand hex?
Yes. Both #RGB (e.g. #f00 for red) and #RRGGBB (e.g. #ff0000) formats are supported.
Which color formats are supported?
HEX (`#FF5733`), RGB (`rgb(255, 87, 51)`), HSL (`hsl(11, 100%, 60%)`), and HSV/HSB. Paste any one format and the tool converts to all the others simultaneously.
What is the difference between HSL and HSV?
Both use Hue, Saturation, and a brightness dimension. HSL uses Lightness (50% is pure color, 100% is white); HSV uses Value (100% is pure color). HSL is better for CSS; HSV is common in design tools like Photoshop.
Will these colors look the same on every screen?
No. sRGB is the assumed color space for all three formats, but wide-gamut displays, HDR monitors, and mobile screens render colors slightly differently. For print work, use LAB or CMYK instead.

Related Tools