Color Converter

Convert HEX, RGB, HSL, and HSV colors.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter a HEX color and get the equivalent rgb() and hsl() values, ready for CSS. Both 6-digit (#1a73e8) and 3-digit (#fff) codes work, with or without the # sign. HSL values are rounded to whole numbers.

How to use

1
Step 1
Type a HEX color such as #1a73e8.
2
Step 2
Press Generate.
3
Step 3
Copy the rgb() or hsl() value.

How it works

The hex pairs are read as red, green and blue from 0 to 255. HSL is then calculated from those: hue in degrees, and saturation and lightness as percentages, all rounded. A 3-digit hex is expanded by doubling each digit, so #fff is #ffffff.

Worked example

Google blue

Input
#1a73e8
Output
{ "hex": "#1a73e8", "rgb": "rgb(26, 115, 232)", "hsl": "hsl(214, 82%, 51%)" }
Walkthrough
1a is 26, 73 is 115 and e8 is 232 in decimal. The hsl value is rounded, so converting back may be off by one.

Limitations

  • Input must be hex. rgb(), hsl() and named colors like tomato are not accepted.
  • No alpha channel (8-digit hex) and no HSV output.
  • Because HSL is rounded, round-tripping through it can shift a colour slightly.

Questions

How do I convert HEX to RGB?
Enter the hex code and press Generate. The rgb() value is listed.
How do I convert HEX to HSL?
The same result also lists the hsl() value for the colour.
Does it work with #fff?
Yes, 3-digit hex is expanded to 6 digits before converting.
Can I convert RGB to HEX?
Not in this tool, which takes hex input only.

Features

  • HEX to RGB and HSL
  • 3- and 6-digit hex
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • Learn JSON - Full Crash Course

    freeCodeCamp.org

    JSON is the payload format behind many developer tools here.

    Watch on YouTube
  • What Is A RESTful API?

    Traversy Media

    API context for JWT, JSON, and encoding utilities.

    Watch on YouTube