Skip to main content

HEX ↔ RGB ↔ HSL Converter + Palette + Contrast

Convert colors between HEX, RGB, and HSL formats. Generate tints, shades, tones, and harmony palettes. Check WCAG contrast ratios for accessibility compliance.

Loading calculator...

A developer grabs #1A73E8 from the style guide, pastes it into CSS, then needs the same value as rgba() for a transparent overlay. Eyeballing the conversion is how you end up with a button one shade off the nav bar. Converting HEX to RGB or HSL is pure arithmetic, but doing it by hand invites rounding mistakes — especially when you also need a WCAG contrast check.

Paste a colour in any notation to get all three formats, contrast ratios, and harmony palettes ready to copy into code.

HEX, RGB, and HSL — Three Notations for the Same Pixel

HEX is shorthand for RGB: #1A73E8 means R 26, G 115, B 232. HSL rewrites it as hue 217°, saturation 82%, lightness 51% — same pixel, different mental model. HEX is compact for design tokens. RGB is native to canvas APIs. HSL maps to how humans think: “make it lighter” means raise L, “mute it” means lower S.

The gotcha: HEX rounds to 8-bit integers (0–255). HSL-to-RGB math often produces fractional values that get floored, so a round trip can shift by ±1 per channel. Pick one canonical format for your tokens and derive the rest.

Why HSL Beats RGB for Generating Tints, Shades, and Palettes

Lightening in RGB means raising all three channels by an amount that depends on the hue — guesswork. In HSL you bump L from 50% to 70% and the tint is done; hue and saturation stay put. Building a five-step scale is a single loop over the lightness axis.

The limit is perceptual uniformity. HSL treats all hues as equally bright at L 50, but yellow looks far brighter than blue at the same L value. CSS’s oklch() fixes this with a perceptually uniform lightness channel — better for precision accessibility palettes.

WCAG Contrast Ratios: The Numbers Behind Accessible Text

The WCAG 2.1 guidelines require 4.5:1 for normal text and 3:1 for large text (18px bold / 24px regular). The ratio uses relative luminance — a weighted sum of linearised RGB, not raw 0–255 values. A pair that “looks fine” can fail because the eye compensates better than users with reduced vision.

Alpha complicates it. An rgba() overlay at 60% opacity over white produces a different effective colour than the same overlay over black. Test contrast with the composited colour, not the alpha value alone.

Harmony Rules: Complementary, Analogous, and Triadic in Practice

Complementary colours sit 180° apart — maximum contrast, good for CTAs. Analogous span 30° either side — cohesive, low contrast. Triadic places three hues 120° apart — vibrant but hard to balance without muting two of the three.

These rules assume sRGB. On a Display P3 monitor a saturated green clips when exported to HEX — the harmony breaks. Stick to sRGB for web unless you explicitly target wide-gamut via CSS color(display-p3 ...).

Quick Interpretation: What Your Converted Values Tell You

The output gives HEX, RGB, and HSL plus contrast ratios against white and black. If the white ratio falls below 4.5, the colour fails WCAG AA for text on light backgrounds. If both ratios are low, the colour sits in mid-lightness and needs a stronger pairing for readable text.

Fast Clarifications on Color Workflow Pitfalls

  • sRGB gamut clipping. Wide-gamut displays show colours with no exact HEX equivalent. Exporting silently clips to the nearest sRGB point — check after conversion.
  • Dark-mode inversion. Flipping lightness (L 80 → L 20) does not guarantee the same contrast ratio. Re-check every text/background pair after inverting.
  • Alpha and contrast. Transparency changes the composited colour the user actually sees but does not appear in a raw contrast calculation. Test with the flattened value.

Slips that break design reviews: copying three-digit HEX shorthand (#FFF) into a six-digit field and getting #FFF000 instead of #FFFFFF, and assuming CSS named colours match the same HEX across all browsers.

Related tools: Image DPI Calculator when colour accuracy matters alongside print resolution, Password Entropy Estimator for credentials on shared design systems, Regex Tester for validating HEX patterns in code, and API Rate Limit Planner for colour-API endpoints serving palettes at scale.

Conversions assume sRGB and 8-bit-per-channel precision. Contrast ratios follow WCAG 2.1 relative-luminance formulas — they do not replace accessibility audits or testing on actual devices and assistive technologies.

Frequently Asked Questions

What is the difference between HEX, RGB, and HSL?

HEX is a hexadecimal notation (#RRGGBB) representing colors in base-16 (compact format for web, base-16 values 00-FF). RGB uses decimal values (0-255) for Red, Green, and Blue channels (additive color model, native format for screens). HSL uses Hue (0-360°), Saturation (0-100%), and Lightness (0-100%) (perceptual color model, more intuitive for designers). All three can represent the same colors but with different notation systems (same color, different formats). Understanding HEX vs RGB vs HSL helps you see how to choose appropriate format for your needs.

How do I convert HEX to RGB?

Split the HEX code into pairs (RR, GG, BB) and convert each from base-16 to decimal (base-16 to decimal conversion, each pair represents 0-255). For example, #FF5733: FF = 255, 57 = 87, 33 = 51, giving rgb(255, 87, 51) (FF in base-16 = 255 in decimal, 57 in base-16 = 87 in decimal). For short HEX (#RGB), double each character first (#F53 → #FF5533) (short HEX expansion, double each digit). Understanding HEX to RGB conversion helps you see how to convert hexadecimal colors to RGB format.

What is the alpha channel in RGBA and HSLA?

The alpha channel represents opacity, ranging from 0 (fully transparent) to 1 (fully opaque) (alpha channel controls transparency, 0 = transparent, 1 = opaque). In HEX, alpha is represented as two additional characters (#RRGGBBAA) where AA is opacity in base-16 (HEX alpha format, two additional characters). A value of 0.5 means 50% opacity, allowing background colors to show through (50% opacity, background visible). Understanding alpha channel helps you see how to control color transparency.

What is the difference between tints, shades, and tones?

Tints are created by adding white (increasing lightness), making colors lighter and more pastel (tints = lighter colors, increase lightness in HSL). Shades are created by adding black (decreasing lightness), making colors darker (shades = darker colors, decrease lightness in HSL). Tones are created by adding gray (reducing saturation), making colors more muted and sophisticated (tones = muted colors, reduce saturation in HSL). Understanding tints vs shades vs tones helps you see how to create different color variations.

What is a complementary color?

Complementary colors are opposite each other on the color wheel (180° apart in hue) (complementary colors = opposite hues, 180° separation). They create high contrast and visual interest when used together (high contrast combinations, visually striking). For example, blue (#0000FF) and orange (#FF8000) are complementary (blue and orange example, opposite on color wheel). Use complementary colors sparingly for accents rather than large areas (complementary color usage, accents not large areas). Understanding complementary colors helps you see how to create high-contrast color combinations.

How do I create an analogous color palette?

Analogous palettes use colors adjacent on the color wheel, typically within 30° of each other (analogous colors = adjacent hues, typically ±30°). Start with a base hue, then add colors at +30° and -30° (or adjust the spread) (analogous palette generation, base hue ± spread). These palettes are harmonious and commonly found in nature (harmonious color combinations, natural palettes). Understanding analogous palettes helps you see how to create harmonious color combinations.

What contrast ratio do I need for accessible text?

WCAG 2.1 requires a minimum contrast ratio of 4.5:1 for normal text (AA level) (WCAG AA requirement, 4.5:1 for normal text) and 3:1 for large text (18pt+ or 14pt bold) (WCAG AA Large requirement, 3:1 for large text). For enhanced accessibility (AAA level), aim for 7:1 for normal text (WCAG AAA requirement, 7:1 for normal text). Use the contrast checker to verify your color combinations (contrast checking tool, verify accessibility). Understanding WCAG contrast requirements helps you see how to ensure text readability and accessibility compliance.

Why does my color look different on different screens?

Colors can appear differently due to: display calibration differences (different displays have different calibrations, affects color appearance), color space variations (sRGB vs Adobe RGB, different color spaces), ambient lighting conditions (lighting affects perceived color, different environments), and screen technologies (LCD vs OLED, different technologies). Always test your colors on multiple devices and consider using color-managed workflows for critical work (color testing, multiple devices, color-managed workflows). Understanding color appearance variations helps you see why colors may look different across devices.

What is relative luminance?

Relative luminance measures the perceived brightness of a color, accounting for how the human eye perceives different wavelengths (relative luminance = perceived brightness, accounts for eye sensitivity). It's calculated using weighted RGB values: 0.2126×R + 0.7152×G + 0.0722×B (after gamma correction) (relative luminance formula, weighted RGB with gamma correction). This is used in WCAG contrast calculations (relative luminance in contrast, WCAG calculations). Understanding relative luminance helps you see how to calculate perceived brightness for contrast calculations.

How do I choose colors for dark mode?

For dark mode: reduce saturation (highly saturated colors can appear too vibrant on dark backgrounds, reduce saturation for dark mode), increase lightness (colors need to be lighter on dark backgrounds, increase lightness for visibility), and always verify contrast ratios (check contrast for accessibility, verify WCAG compliance). A common approach is to use tints of your light-mode colors rather than the same values (dark mode color strategy, use tints not same values). Understanding dark mode color selection helps you see how to adapt colors for dark mode interfaces.

What is a triadic color palette?

Triadic palettes use three colors evenly spaced on the color wheel (120° apart in hue) (triadic colors = three hues, 120° separation). For example, red (0°), green (120°), and blue (240°) form a triadic palette (triadic example, RGB colors). These palettes are balanced and colorful, providing good contrast while maintaining harmony (triadic characteristics, balanced and colorful). Understanding triadic palettes helps you see how to create balanced color combinations.

What factors affect color conversion and palette generation that this tool doesn't account for?

This tool does not account for many factors that affect real-world color design: actual display capabilities (display calibration, color space variations, ambient lighting affect color appearance), color perception (individual differences, color blindness, viewing conditions affect perceived color), design context (brand guidelines, cultural associations, design trends affect color choices), printer capabilities (printer color gamut, paper type, ink quality affect print colors), and many other factors. Real color design accounts for these factors using detailed design services, color testing, design analysis, and comprehensive color planning. Understanding these factors helps you see why professional design services are necessary for comprehensive color design systems.

Explore More Tech & Dev Utilities

Calculate file transfer times, subnet configurations, password entropy, and more with our suite of developer tools.

How helpful was this calculator?

HEX/RGB/HSL Converter: Palette + WCAG Contrast