← Back to Blog

    HEX, RGB, HSL and CMYK Explained: How Color Formats Convert

    October 2026 · 6 min read · By Macrae Myint

    A designer hands you #3B82F6, your CSS wants hsl(), and the printer asks for CMYK. They are all descriptions of the same color, expressed with different math. This guide explains what each format measures, shows real conversions, and covers the one calculation that decides whether text is readable: contrast ratio. Every number on this page is computed by the same code as the ToolsForge Color Tools.

    What each format actually stores

    • RGB gives the amount of red, green and blue light, each from 0 to 255. It matches how screens emit color.
    • HEX is RGB written in base 16. #3B82F6 is three byte pairs: 3B = 59 red, 82 = 130 green, F6 = 246 blue. A three-digit form such as #0AF doubles each digit to #00AAFF.
    • HSL describes hue as an angle on the color wheel (0 to 360 degrees), plus saturation and lightness as percentages. It is easier to reason about: raising lightness makes a color lighter without changing its hue.
    • HSB (also called HSV) uses hue, saturation and brightness. Design tools such as Photoshop-style pickers commonly use it. HSL and HSB share hue but compute saturation differently, so the same saturation number means different colors in each.
    • CMYK describes ink on paper: cyan, magenta, yellow and black percentages. The formula used here is the naive mathematical conversion from RGB. Real print workflows use ICC color profiles, so treat CMYK numbers from any simple converter as approximate, not press-ready.

    Worked conversions

    HEXRGBHSLHSBCMYK
    #3B82F659, 130, 246217°, 91%, 60%217°, 76%, 96%76, 47, 0, 4
    #FF0000255, 0, 00°, 100%, 50%0°, 100%, 100%0, 100, 100, 0
    #10B98116, 185, 129160°, 84%, 39%160°, 91%, 73%91, 0, 30, 27
    #808080128, 128, 1280°, 0%, 50%0°, 0%, 50%0, 0, 0, 50
    #0F172A15, 23, 42222°, 47%, 11%222°, 64%, 16%64, 45, 0, 84

    Values are rounded to whole numbers, so converting back and forth can shift a channel by one. That is rounding, not a bug. Notice the gray #808080: with equal red, green and blue it has no hue or saturation at all, only lightness.

    Contrast: the number that decides readability

    The Web Content Accessibility Guidelines (WCAG 2.x) define contrast as a ratio between 1:1 (identical colors) and 21:1 (black on white). Level AA asks for at least 4.5:1 for normal text and 3:1 for large text; level AAA asks for 7:1 and 4.5:1. The ratio comes from each color's relative luminance, which weights green most heavily because the eye is most sensitive to it. Some results:

    TextBackgroundRatioNormal text AA (4.5:1)
    #0F172A#FFFFFF17.85:1Pass
    #808080#FFFFFF3.95:1Fail
    #3B82F6#FFFFFF3.68:1Fail
    #1D4ED8#FFFFFF6.70:1Pass

    A mid-gray or a bright blue can look fine to the person who chose it and still fall short of the threshold. Measuring beats eyeballing, though WCAG 2 contrast is a simplified model, and newer perceptual methods such as APCA can disagree at the margins.

    Which format should you use?

    • Use HEX when copying brand colors between tools; it is compact and universal in CSS.
    • Use HSL when you need to derive variations, such as hover states and tints, by adjusting lightness or saturation.
    • Use RGB when you need to add opacity with rgb(… / 50%) or do arithmetic on channels.
    • Use CMYK only as a rough guide; ask your printer for the profile they expect.

    Convert and check a color

    1. Open Color Tools and type or pick a HEX value (3 or 6 digits).
    2. Copy the RGB, HSL, HSB or CMYK value you need.
    3. Enter a background color in the contrast checker and read the ratio against the thresholds above.

    All conversions are plain arithmetic in your browser; no color or image data is sent anywhere.

    Convert colors and check contrast

    HEX, RGB, HSL, HSB and CMYK, shades, palettes and a WCAG contrast checker. Free.

    Open Color Tools →