CS

Loading workspace...

Preparing your tools

Guide

Convert HEX, RGB and HSL Values for CSS

Convert HEX colors to RGB or HSL, preview the result and understand contrast, rounding and design-token consistency.

Introduction

Introduction

A design file may specify a HEX color while a component's CSS uses HSL or RGB. Color Converter helps translate supported color values without recalculating channels manually. It also offers a live swatch, which is useful for checking whether the input is approximately the color intended.

The converter does not choose accessible color combinations, generate brand strategy or tell you whether a palette meets contrast requirements. Those are separate design decisions.

Step-by-step guide

1

Step 1

Open [Color Converter](/tools/color-converter).

2

Step 2

Enter a supported HEX, RGB or HSL value, such as `#336699`.

3

Step 3

Run the conversion and inspect the equivalent values in the other formats.

4

Step 4

Compare the preview against your reference mockup.

5

Step 5

Copy the target representation into a component stylesheet or design-token file.

Benefits

  • ✓ Store reviewed colors as central design tokens and avoid copying approximations.
  • ✓ Confirm contrast in the actual interface, not just the preview swatch.
  • ✓ Test hover, disabled and dark-mode states separately.
  • ✓ Compare conversions at the same color profile and opacity.
  • ✓ Use [CSS Formatter](/tools/css-formatter) to improve stylesheet readability after updating values.

Best practices

  • • Store reviewed colors as central design tokens and avoid copying approximations.
  • • Confirm contrast in the actual interface, not just the preview swatch.
  • • Test hover, disabled and dark-mode states separately.
  • • Compare conversions at the same color profile and opacity.
  • • Use [CSS Formatter](/tools/css-formatter) to improve stylesheet readability after updating values.

More details

Convert a known reference color

  1. Open Color Converter.
  2. Enter a supported HEX, RGB or HSL value, such as #336699.
  3. Run the conversion and inspect the equivalent values in the other formats.
  4. Compare the preview against your reference mockup.
  5. Copy the target representation into a component stylesheet or design-token file.

For the example #336699, the RGB channels are 51, 102 and 153. The equivalent HSL representation is approximately 210 degrees hue, 50% saturation and 40% lightness. The values describe the same nominal sRGB color using different coordinate systems.

HEX versus RGB versus HSL

Six-digit hexadecimal notation lists red, green and blue channels as two hex digits each. RGB uses decimal channel values, usually from 0 to 255 in its common legacy syntax. HSL expresses hue, saturation and lightness, which can make some color adjustments easier to reason about.

The formats are not different image files. They are ways to express a color in CSS and design tooling. When converting, be aware that rounding can slightly change the displayed numbers. Always keep a single source of truth for a design token instead of repeatedly converting back and forth.

Designing for contrast

A bright accent color that looks attractive in a swatch may be hard to read as small text on a similar background. Use a contrast checker and evaluate normal text, large text, focus indicators and interactive states separately. HSL lightness is not equivalent to perceptual lightness, so changing it by ten points does not guarantee a predictable contrast improvement.

If you are designing a family of related colors rather than converting one existing color, use Color Palette Generator to explore harmony-based options before testing accessibility.

Troubleshooting

If an input is rejected, check that it uses a supported syntax, complete HEX digits and in-range channel values. If a design editor shows a different color, verify its color profile and the rendering environment. CSS sRGB representations can differ from device-managed wide-gamut previews. A missing alpha channel also matters when comparing translucent overlays.

Related tools

Continue your workflow with these matching tools.

Related, practical walkthroughs for the tools used in this guide.

Ready to run this workflow?

Upload your file and apply these settings in under a minute.