Free tool · technology
Hex to RGB Converter
Convert a hex colour to RGB and HSL, with a live swatch.
Colours
Enter any hex value or use the picker. Everything is calculated in your browser.
Result
- HEX
- #a3e635
- RGB
- 163, 230, 53
- HSL
- 83°, 78%, 55%
Embed this on your site
Free to embed. The attribution link stays with the widget, and the calculator keeps working exactly as it does here.
<iframe src="https://thedigitalstash.net/embed/hex-to-rgb" title="The Digital Stash calculator" width="100%" height="720" style="border:0;max-width:100%" loading="lazy"></iframe>
Understanding the Hex to RGB Converter
Digital displays rely on specific colour models to render images and text. While a hexadecimal (hex) code is a standard way to represent colours in web design, other formats like Red, Green, Blue (RGB) and Hue, Saturation, Lightness (HSL) are frequently required for software development, graphic design, and hardware configuration. This tool translates a six-character hex string into these alternative formats, allowing for quick adjustments and cross-platform compatibility.
The Conversion Method
A hex code is a six-digit alphanumeric string preceded by a hash symbol. Each pair of digits represents the intensity of one of the three primary colours: Red, Green, and Blue. Because hex uses base-16 (hexadecimal) notation, the digits range from 0 to 9 and letters A to F.
To convert this to RGB, the tool separates the string into three pairs. Each pair is converted from base-16 to base-10 (decimal). For example, the first pair represents the intensity of red, the second represents green, and the third represents blue. Each decimal value falls within the range of 0 to 255.
The conversion to HSL involves a mathematical transformation of the RGB values. First, the intensity values are normalised to a range between 0 and 1. The tool identifies the maximum and minimum values to calculate lightness. It then determines saturation based on the difference between these extremes. Finally, the hue is calculated as an angle on the colour wheel, expressed in degrees from 0 to 360.
A Worked Example
Consider the hex code #2A5D8E.
- Splitting the code: The string is split into three pairs: 2A (Red), 5D (Green), and 8E (Blue).
- Hex to Decimal conversion:
- Red: 2A becomes (2 * 16) + 10 = 42.
- Green: 5D becomes (5 * 16) + 13 = 93.
- Blue: 8E becomes (8 * 16) + 14 = 142.
- RGB result: The colour is represented as rgb(42, 93, 142).
- HSL conversion: Based on these decimal values, the tool calculates the hue, saturation, and lightness. The result is approximately hsl(210, 54%, 36%).
The live swatch displays these results immediately, allowing you to confirm that the colour matches your expectations before copying the values into your project.
Interpreting the Results
The RGB format is the standard for most screen-based applications. If you are working in CSS or web development, the rgb() function is a reliable way to define colours. Some environments also accept an alpha channel, denoted as RGBA, which introduces transparency.
The HSL format is often preferred for manual colour selection. Because HSL mirrors human perception of colour better than RGB, it is easier to adjust hue (the colour itself), saturation (the intensity), or lightness (the brightness) independently. If you need to create a lighter version of a colour for a hover effect, increasing the lightness percentage in HSL is more intuitive than adjusting the RGB values.
Assumptions and Limits
This tool assumes the input hex code follows the standard six-digit format. While many systems accept short-hand three-digit hex codes (such as #FFF instead of #FFFFFF), this converter is designed to process the full six-digit string.
The primary limitation of this tool is its dependence on the sRGB colour space. Digital screens generally operate within the sRGB gamut, which is the assumption for all RGB and HSL values generated here. If you are working in a wider colour space like Display P3 or Adobe RGB, the numerical values provided by this tool will not accurately represent those colours. Furthermore, this tool does not provide conversion to print-specific colour models such as CMYK. CMYK relies on physical ink densities rather than light emission, and the mathematical relationship between RGB and CMYK is dependent on specific printer profiles and paper types, which cannot be reliably calculated with a generic formula.
Who This Tool Is Not For
This tool is not intended for professional print production or industrial colour matching. If you are preparing files for commercial offset printing, you require specialised colour management software that handles ICC profiles and CMYK separation. Using simple RGB to CMYK conversions often leads to colour shifting and unexpected output results.
Additionally, this tool is not suitable for users who require accessibility auditing for contrast ratios or those performing complex colour space transformations, such as Lab or XYZ calculations. If your work involves scientific research or precise colour engineering for high-fidelity displays, you should use professional-grade software that accounts for gamut mapping and chromatic adaptation. For the average web designer or front-end developer, however, this converter provides the necessary values for standard screen-based tasks.
More tools like this
Add Line Numbers
Number every line in a list, with aligned columns for code and checklists.
Run itAge Calculator
Exact age in years, months and days, plus days until the next birthday.
Run itAnagram Checker
Check whether two words or phrases use exactly the same letters.
Run it