← Back to FreeTextUtils  · 

📅 Updated: June 1, 2026 | ⏱️ Reading time: 12 minutes | ✍️ By FreeTextUtils Team

What Are Color Formats?

Color on digital displays is represented using different mathematical models, called color spaces. Each color format describes colors in a specific way, suited for different purposes. The three most common formats in web development and digital design are HEX (hexadecimal), RGB (Red, Green, Blue), and HSL (Hue, Saturation, Lightness). Understanding these formats and how to convert between them is essential for web designers, UI/UX designers, front-end developers, and digital artists.

HEX codes are the most widely used in HTML and CSS, RGB is the native format for displays and design software, and HSL offers the most intuitive way to think about and manipulate colors. Each format can represent the same 16.7 million colors in the standard sRGB gamut, but they express color information differently. Mastering all three formats gives you the flexibility to work in whatever color model is most convenient for your current task.

HEX Color Codes

HEX codes are six-digit hexadecimal (base-16) values preceded by a hash (#), representing the red, green, and blue components of a color. The format is #RRGGBB, where each pair of hex digits ranges from 00 (0) to FF (255).

HEX Shorthand

When each pair of hex digits is identical (like #FF6644), the code can be shortened to three digits: #F64. The browser expands each digit by doubling it: #F64 becomes #FF6644. This works for colors like white (#FFF = #FFFFFF), black (#000 = #000000), and grays where each channel is a multiple of 17.

HEX with Alpha (RGBA)

CSS Color Level 4 introduced 8-digit HEX codes: #RRGGBBAA, where AA represents the alpha channel (opacity). For example, #FF000080 is red at 50% opacity. The 4-digit shorthand (#RGBA) is also available.

Reading HEX Values

#2563EB (our primary brand color) breaks down as:

  • Red: 25 (hex) = 37 (decimal)
  • Green: 63 (hex) = 99 (decimal)
  • Blue: EB (hex) = 235 (decimal)

This gives us RGB(37, 99, 235), a rich blue.

RGB and RGBA

RGB represents colors as three numerical values for red, green, and blue, each ranging from 0 to 255. The format is rgb(red, green, blue). RGBA adds a fourth parameter for alpha (opacity), ranging from 0.0 (transparent) to 1.0 (opaque).

How RGB Works

RGB is an additive color model: colors are created by adding light. When all three channels are at 0 (rgb(0, 0, 0)), the result is black (no light). When all three are at 255 (rgb(255, 255, 255)), the result is white (full light). Equal values of all three channels produce grays: rgb(128, 128, 128) is middle gray.

RGB Percentages

CSS also supports percentage values: rgb(100%, 0%, 0%) is the same as rgb(255, 0, 0) (pure red). Percentages range from 0% to 100%, where 100% corresponds to 255.

When to Use RGB

RGB is the native language of computer monitors, so it is ideal when you need precise control over display output. Design tools like Photoshop and Figma display RGB values. If you are working with hardware, LED strips, or color calibration, RGB is the format you will use.

HSL and HSLA

HSL represents colors using three parameters that are more intuitive for humans: Hue, Saturation, and Lightness. The format is hsl(hue, saturation%, lightness%).

Hue (0-360)

Hue is the color type, measured in degrees on a color wheel: 0° = red, 120° = green, 240° = blue, 360° = back to red. The hue determines the base color without any tinting or shading.

Saturation (0-100%)

Saturation is the intensity or purity of the color. 0% is completely desaturated (gray), 100% is fully saturated (pure hue). Decreasing saturation moves the color toward gray without changing the hue or lightness.

Lightness (0-100%)

Lightness is the brightness of the color. 0% is black (regardless of hue or saturation), 100% is white, and 50% is the pure hue. This is the most intuitive dimension: you can think of it as how much white or black is mixed into the color.

Why HSL Is Powerful

HSL makes it easy to create color schemes. To create a darker shade of the same color, reduce lightness. To create a less intense version, reduce saturation. To create complementary colors, add or subtract 180° from the hue. These operations are natural in HSL but require complex calculations in HEX or RGB.

How to Convert Between Color Formats

HEX to RGB

Split the 6-digit HEX into three 2-digit pairs, convert each from hexadecimal to decimal:

  • #FF = 255, #00 = 0, #80 = 128
  • #FF0080 = rgb(255, 0, 128)

RGB to HEX

Convert each decimal value to a 2-digit hexadecimal:

  • rgb(255, 0, 128) = #FF + 00 + 80 = #FF0080

RGB to HSL

The conversion involves normalizing RGB values to 0-1, finding the min and max, and calculating hue, saturation, and lightness:

  1. Lightness = (max + min) / 2
  2. Saturation = (max - min) / (1 - |2 * Lightness - 1|)
  3. Hue depends on which channel is the maximum, with specific angle offsets for each channel

HSL to RGB

This is the reverse calculation. The hue determines which primary color dominates, saturation adjusts the greyness, and lightness sets the brightness level. The algorithm uses helper values called chroma and match values to compute the final RGB numbers.

Common Colors Reference Table

Color Swatch HEX RGB HSL
Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Green#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
Gray#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
Yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
Cyan#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
Magenta#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
Orange#FFA500rgb(255, 165, 0)hsl(39, 100%, 50%)
Purple#800080rgb(128, 0, 128)hsl(300, 100%, 25%)
Pink#FFC0CBrgb(255, 192, 203)hsl(350, 100%, 88%)
Brown#A52A2Argb(165, 42, 42)hsl(0, 59%, 41%)
Navy#000080rgb(0, 0, 128)hsl(240, 100%, 25%)
Teal#008080rgb(0, 128, 128)hsl(180, 100%, 25%)

Frequently Asked Questions

Q: Which color format should I use in CSS?

A: There is no single best format. HEX is most common and compact. HSL is most readable and easiest to adjust programmatically. RGB is best when working with opacity or when values come from design tools. Use whichever is most convenient for your use case.

Q: How do I add transparency to a HEX color?

A: Use the 8-digit HEX format: #RRGGBBAA. For example, #FF000080 is 50% transparent red. Alternatively, use RGBA or HSLA in CSS: rgba(255, 0, 0, 0.5).

Q: Are there colors that HEX cannot represent?

A: Standard 6-digit HEX covers the full sRGB gamut (16.7 million colors). Wide-gamut displays (DCI-P3, Rec. 2020) require newer CSS formats like color(display-p3 1 0 0) for colors outside sRGB.

Q: What is the difference between HSL and HSV/HSB?

A: HSL uses Lightness (ranges from black to white through pure color). HSV/HSB uses Value/Brightness (ranges from black to pure color). HSL has two endpoints (black and white), while HSV has one (black). Most CSS and web tools use HSL.

Q: How do I convert a color name to HEX?

A: CSS defines 148 named colors (like red, blue, rebeccapurple). Our color converter accepts named colors as input and returns their HEX, RGB, and HSL equivalents. Just type the name and the tool handles the conversion.

Q: What about CMYK for print?

A: CMYK (Cyan, Magenta, Yellow, Key/Black) is a subtractive color model used for printing. RGB and CMYK have different gamuts, so conversion is not always exact. Our tool focuses on screen-based formats (HEX, RGB, HSL). For print projects, use dedicated design software.

Ready to Convert Colors?

Use our free online color converter to transform between HEX, RGB, and HSL formats instantly:

  • Convert HEX to RGB, RGB to HSL, and all other combinations
  • Built-in color preview swatches
  • Supports named CSS colors
  • 100% browser-based processing
  • Copy results with one click
Go to Color Converter Tool