ratio.

Find a tool

Browse all tools and categories β†—
DESIGN

HEX RGB and HSL Color Converter

Convert opaque sRGB color codes between HEX, integer RGB and HSL. See unrounded channel values and the nearest 8-bit HEX representation.

Enter your values

01 / INPUT
Calculated on your device

YOUR CALCULATION

Result

β€”

Calculation steps

Work through one step at a time or reveal the complete calculation. The steps use your current inputs.

    How to calculate

    Interpret the selected opaque sRGB input. Normalize RGB channels, recover hue from the dominant channel, and derive lightness and saturation from the maximum and minimum. Round channels only for the 8-bit HEX/RGB output.

    HSL lightness=(max RGB+min RGB)/2; HEX encodes rounded 8-bit sRGB channels

    Worked example

    HEX #336699 is RGB (51,102,153) and HSL (210Β°,50%,40%). The shorthand #F80 expands to #FF8800.

    Assumptions and input details

    HEX accepts exactly three or six hexadecimal digits with optional #. RGB inputs are integers 0–255. HSL hue is normalized modulo 360Β° (entered magnitude at most 1e9Β°); saturation/lightness are 0–100%. HSL can produce fractional RGB channels; HEX and integer RGB round to nearest 8-bit values. The HSL output describes the unrounded color, so converting through HEX may slightly change it. Achromatic colors have undefined hue, shown as such with CSS hue 0. Opaque sRGB only: no alpha, CMYK, ICC profiles, wide-gamut conversion, color matching or contrast certification.

    References: W3C CSS Color conversions

    Using this calculator

    Can I enter my own problem?

    Yes. Replace the example values with your own inputs. The result, calculation steps, tables and applicable diagrams update from those inputs. Blank or invalid values clear the result; example values are never silently substituted for missing inputs.

    Are the results exact?

    Results use floating-point arithmetic and displayed rounding. Read the formula, assumptions and any stated data precision before interpreting the result.

    Is my input uploaded?

    The calculation runs in your browser. No account, file upload or external AI service is required. Inputs are not saved between page reloads.

    RELATED TOOL Β· DESIGNPrint Size and Image Resolution Calculator

    Convert pixel dimensions, print dimensions and pixels per inch. Find physical print size, required whole pixels or effective image resolution.

    RELATED TOOL Β· COMPUTINGScreen Size Calculator

    Enter a screen diagonal and pixel resolution to calculate active width, height, aspect ratio, pixel density and pitch, with a dimensioned screen diagram.

    RELATED TOOL Β· COMPUTINGNumber Base Converter

    Convert a signed integer between bases 2–36 using exact arithmetic. Compare binary, octal, decimal, hexadecimal and base-36 values with place-value steps.

    ADVERTISEMENT

    Reserved advertising space.