Tools

Color Code Converters | HEX, RGB, HSL

Convert HEX, RGB, HSL, HSV, HWB, CMYK, Lab, LCH, decimal colors, check WCAG contrast, generate palettes, and copy CSS values.

Color Code Converters

Convert colors between HEX, RGB, RGBA, HSL, HSLA, HSV/HSB, HWB, CMYK, decimal integer, CIE XYZ, CIE Lab, and LCH. Check WCAG contrast, generate color palettes, create tints and shades, copy CSS-ready values, and export color tables.

HEX to RGB RGB to HSL HSV / HSB HWB CMYK Decimal color Lab / LCH WCAG contrast Palette generator CSS variables CSV export

1. Enter Color

Supports HEX, RGB/RGBA, HSL/HSLA, and a practical set of common CSS color names.

Contrast Checker

Options

2. Converted Result

Preview
Primary HEX value #40A951

This color is converted into web, design, print-style, and accessibility-friendly formats.

RGB rgb(64, 169, 81)
HSL hsl(130, 45%, 46%)
Contrast 3.13:1
WCAG Large AA
Color Conversion Flow Input HEX / RGB / HSL sRGB R, G, B channels Outputs CSS + contrast #40A951 → RGB/HSL/CMYK/Lab Contrast and palette update automatically.

3. All Color Code Outputs

FormatConverted ValueBest Use

Contrast and Accessibility

Accessibility MetricValueInterpretation

Color Harmony and Palette

Channel Summary

CSS Variable Output

\[ \text{HEX} = \#RRGGBB,\quad R,G,B\in[0,255] \]

Color Conversion Formulas

A color converter starts with a standard internal representation. For web colors, the practical base format is often sRGB with red, green, blue, and optional alpha channels. Each RGB channel normally ranges from 0 to 255.

\[ R,G,B\in[0,255] \] \[ r=\frac{R}{255},\quad g=\frac{G}{255},\quad b=\frac{B}{255} \]

HEX color is simply RGB written in base 16:

\[ \#RRGGBB \] \[ RR=\operatorname{hex}(R),\quad GG=\operatorname{hex}(G),\quad BB=\operatorname{hex}(B) \]

HSL uses hue, saturation, and lightness. First define:

\[ C_{\max}=\max(r,g,b) \] \[ C_{\min}=\min(r,g,b) \] \[ \Delta=C_{\max}-C_{\min} \] \[ L=\frac{C_{\max}+C_{\min}}{2} \]

Hue depends on the largest channel:

\[ H= \begin{cases} 0,&\Delta=0\\ 60\left(\frac{g-b}{\Delta}\bmod 6\right),&C_{\max}=r\\ 60\left(\frac{b-r}{\Delta}+2\right),&C_{\max}=g\\ 60\left(\frac{r-g}{\Delta}+4\right),&C_{\max}=b \end{cases} \] \[ S= \begin{cases} 0,&\Delta=0\\ \frac{\Delta}{1-|2L-1|},&\Delta\ne0 \end{cases} \]

HSV, also called HSB, uses value instead of lightness:

\[ V=C_{\max} \] \[ S_{HSV}= \begin{cases} 0,&C_{\max}=0\\ \frac{\Delta}{C_{\max}},&C_{\max}\ne0 \end{cases} \]

CMYK is a print-style model. A simple RGB-to-CMYK conversion is:

\[ K=1-\max(r,g,b) \] \[ C=\frac{1-r-K}{1-K},\quad M=\frac{1-g-K}{1-K},\quad Y=\frac{1-b-K}{1-K} \]

WCAG contrast uses relative luminance. For each normalized sRGB channel \(c\):

\[ c_{\text{linear}}= \begin{cases} \frac{c}{12.92},&c\le0.04045\\ \left(\frac{c+0.055}{1.055}\right)^{2.4},&c>0.04045 \end{cases} \] \[ L=0.2126R_{\text{linear}}+0.7152G_{\text{linear}}+0.0722B_{\text{linear}} \] \[ \text{Contrast Ratio}=\frac{L_1+0.05}{L_2+0.05} \]

Complete Guide to Color Code Conversion

Color code conversion is the process of translating a color from one notation or color model into another. Web designers, developers, brand designers, teachers, students, marketers, UI/UX designers, accessibility reviewers, and content creators often need the same color in different formats. A designer might receive a HEX code from a brand guide, but the CSS animation needs HSL. A print vendor may ask for CMYK-style values. A developer may need RGBA for transparency. An accessibility reviewer may need relative luminance and contrast ratio. This tool brings those conversions into one workflow.

The most common web color format is HEX. A HEX color such as #40A951 represents red, green, and blue channel values in hexadecimal notation. The first two digits are red, the next two are green, and the last two are blue. Because hexadecimal is base 16, each two-character pair can represent values from 00 to FF, which corresponds to 0 through 255 in decimal. This gives each RGB channel 256 possible values.

RGB notation is more direct for many beginners. A color such as rgb(64, 169, 81) means red is 64, green is 169, and blue is 81. In additive color mixing, red, green, and blue light combine to create the colors displayed on screens. When all three channels are 0, the result is black. When all three are 255, the result is white. Equal channel values produce grays.

RGBA adds an alpha channel. Alpha describes opacity. An alpha value of 1 is fully opaque, while 0 is fully transparent. A value like 0.5 is semi-transparent. In CSS, alpha can be written in several ways, such as rgba(64, 169, 81, 0.5) or modern slash notation like rgb(64 169 81 / 0.5). Alpha affects how the color looks when it is composited over a background.

HSL stands for hue, saturation, and lightness. It is often easier for humans to adjust than RGB. Hue is the angle around the color wheel. Red is near 0 degrees, green is near 120 degrees, and blue is near 240 degrees. Saturation controls how colorful or gray the color is. Lightness controls how dark or light it is. Designers often use HSL to create tints, shades, and related color variations.

HSV, also called HSB, stands for hue, saturation, and value or brightness. It is common in design tools and color pickers. HSV is useful when thinking in terms of brightness. HSL and HSV use the same hue idea but define saturation and brightness/lightness differently. This is why the same RGB color can have different saturation numbers in HSL and HSV.

HWB stands for hue, whiteness, and blackness. It is another cylindrical color model that can be intuitive for adjusting how much white or black is mixed into a hue. Although HWB is less common than RGB and HSL in everyday CSS workflows, it is part of modern CSS color thinking and can be useful for design-system exploration.

CMYK stands for cyan, magenta, yellow, and key black. It is commonly associated with print workflows. RGB is an additive screen model, while CMYK is a subtractive print-style model. The conversion from RGB to CMYK in this tool is a mathematical approximation, not a replacement for professional color-managed print workflows. Real print output depends on paper, ink, press settings, color profiles, and calibration.

Decimal color is a single integer representation of RGB. A color can be stored as \(R\times65536+G\times256+B\). For example, RGB channels can be packed into a 24-bit integer. This is useful in programming, databases, older graphics systems, and some APIs. The decimal representation is compact but less readable than HEX for most design work.

CIE XYZ, Lab, and LCH are color-science formats. XYZ is a foundational color space based on human color matching. Lab is designed to be more perceptually organized than raw RGB, with lightness and opponent-color axes. LCH is a cylindrical form of Lab that uses lightness, chroma, and hue. These formats are useful for deeper color analysis, perceptual color differences, and modern design discussions.

Modern CSS has been expanding beyond classic HEX, RGB, and HSL. CSS Color Module Level 4 describes additional color functions and spaces, including lab(), lch(), and hwb(). Current browser support varies by feature and version, so production sites should test the formats they use. HEX and RGB remain the safest broadly compatible choices. HSL is also widely supported and practical for design systems.

Contrast checking is one of the most important practical features in a color converter. A color may look attractive but fail accessibility when used as text over a background. WCAG contrast ratio compares the relative luminance of the foreground and background. Higher ratios mean stronger contrast. For normal text, a ratio of 4.5:1 is the common AA target. For large text, 3:1 is the common AA target. AAA targets are higher.

Relative luminance is not a simple average of red, green, and blue. Human vision is more sensitive to green than to red or blue, so the luminance formula weights green heavily. The sRGB channels also need to be linearized before weighting. This is why the WCAG formula looks more complex than a simple brightness average.

Palette generation helps designers build related colors. A complementary color is roughly 180 degrees away on the hue circle. Triadic colors are roughly 120 degrees apart. Analogous colors sit near the original hue. Tints move a color toward white. Shades move it toward black. These relationships are mathematical starting points; a polished palette may still need manual adjustment for contrast, branding, emotion, and visual balance.

Color harmony is not the same as accessibility. A palette can be harmonious but still fail text contrast. A brand color can be beautiful but not suitable for small text on white. Use color harmony for visual direction and contrast checks for readability. For user interfaces, always check text, buttons, links, alerts, charts, and focus states against their backgrounds.

When designing a website, it is helpful to store colors as CSS variables. A variable such as --brand-green: #40A951; can be reused throughout a stylesheet. This makes theme changes easier. It also helps keep a design consistent. This converter creates CSS variable output so users can copy a small design-token block into their stylesheet.

HEX shorthand is another useful detail. A color like #33AAFF can be shortened to #3AF because each pair repeats the same character. But #40A951 cannot be shortened because the pairs do not repeat. Shorthand is compact, but full six-digit HEX is usually clearer for brand systems and documentation.

Alpha HEX uses eight digits, written as #RRGGBBAA. The last two digits represent alpha. For example, alpha 255 is fully opaque, alpha 128 is roughly 50% opacity, and alpha 0 is fully transparent. Some environments support eight-digit HEX; older tools may not. RGBA notation is often clearer when transparency is important.

A color converter can also help debug design inconsistencies. Sometimes a brand guide uses HEX, a Figma file displays RGB, a CSS file uses HSL, and a developer tool displays computed colors in a different syntax. Converting them into a common base reveals whether they are actually the same color or slightly different. Even a one-channel difference can matter in strict branding work.

For education, color conversion is a strong applied-math topic. It uses base conversion, ratios, percentages, cylindrical coordinates, interpolation, luminance weighting, gamma correction, and accessibility thresholds. Students can learn how a screen color becomes numbers and how those numbers can be transformed across models.

This page is not an official exam score calculator. There is no universal score guideline, score table, or next exam timetable for color conversion. It can support computer science, design, accessibility, digital art, web development, and applied mathematics, but official exam schedules and scoring rules must come from the relevant school, course provider, or exam board.

Accuracy note: RGB, HSL, HSV, HWB, and simple CMYK conversions are mathematical conversions. Professional print, photography, cinema, and brand-production workflows may require calibrated monitors, ICC profiles, print proofs, and color-managed software.

Reference Links

Useful references: W3C CSS Color Module Level 4, W3C CSS Color Module Level 5, WCAG 2.2, MDN CSS color values, and MDN HEX color.

How to Use Color Code Converters

  1. Choose an input mode. Use flexible input, RGB fields, HSL fields, HSV fields, CMYK fields, or decimal integer.
  2. Enter your color. Type a HEX code, RGB value, HSL value, named color, or use the color picker.
  3. Click Convert Color. The tool converts the color into web, design, print-style, and accessibility formats.
  4. Check contrast. Enter foreground and background colors to see WCAG contrast ratio and pass/fail guidance.
  5. Review palette swatches. Use complementary, triadic, analogous, tint, and shade colors as starting points.
  6. Copy or export. Copy HEX, copy all outputs, download CSV, or print/save the color report.
FormatExampleBest Use
HEX#40A951Brand guides, CSS, design handoff, quick web use.
RGB / RGBArgb(64, 169, 81)CSS, JavaScript, canvas, transparency with alpha.
HSL / HSLAhsl(130, 45%, 46%)Adjusting hue, saturation, and lightness in design systems.
HSV / HSBhsv(130, 62%, 66%)Design tools and brightness-based color picking.
CMYKcmyk(62%, 0%, 52%, 34%)Approximate print-style conversion; not a full print color-management workflow.
Lab / LCHlab(...), lch(...)Color science, perceptual analysis, advanced color discussions.

Score, Course, and Exam Table Note

Requested ItemStatus for This Color ToolCorrect Guidance
Score guidelinesNot applicableThis is a color conversion and accessibility utility, not an official score calculator.
Score tableNot applicableThere is no universal academic score table for color-code conversion.
Next exam timetableNot applicableUse official school or exam-board sources for course-specific exam dates.
Course relevanceUseful for design, web development, and applied mathSupports base conversion, ratios, percentages, accessibility, UI design, and color theory.

Color Code Converter FAQ

What is a color code converter?

A color code converter translates one color notation into another, such as HEX to RGB, RGB to HSL, HSL to HSV, RGB to CMYK, or RGB to Lab.

What is the difference between HEX and RGB?

HEX and RGB represent the same red, green, and blue channels. HEX writes the channels in base 16, while RGB writes them as decimal values from 0 to 255.

What is HSL used for?

HSL is useful for adjusting hue, saturation, and lightness. Designers often use it to create tints, shades, and related color variations.

Is CMYK conversion exact?

The calculator gives a simple mathematical CMYK approximation. Professional print color requires color profiles, calibrated devices, and proofing.

How is contrast ratio calculated?

Contrast ratio uses relative luminance: \(\text{ratio}=(L_1+0.05)/(L_2+0.05)\), where \(L_1\) is the lighter color and \(L_2\) is the darker color.

What contrast ratio should I aim for?

A common WCAG AA target is 4.5:1 for normal text and 3:1 for large text. AAA targets are 7:1 for normal text and 4.5:1 for large text.

Can I use this for CSS variables?

Yes. The tool creates copy-ready CSS variables with HEX, RGB, HSL, and contrast-friendly values.

Shares:

Related Posts